Part Number Hot Search : 
EM91215B HV9110X AD1674BD C6008 E13009 TCA0372D 3KP54 156682
Product Description
Full Text Search
 

To Download TMP89CH42UG Datasheet File

  If you can't view the Datasheet, Please click here to try to view without PDF Reader .  
 
 


  Datasheet File OCR Text:
  8 bit microcontroller tlcs-870/c1 series tmp89ch42
? 2009 toshiba corporation all rights reserved
considerations for using both mask rom and flash products ? flash memory control registers mask rom products do not contain the flash memory control registers shown in the table below. therefore, a program that accesses these registers operates differently between mask rom and flash products. if you use a flash product to check the operation of a program written for a mask rom product, be sure not to write instructions that access these registers in the program. register name address mask rom product flash product 89cm42, 89ch42 89fm42, 89fh42 flscr1 0x0fd0 not available available flscr2 / flscrm 0x0fd1 flsstb 0x0fd2 spcr 0x0fd3 ? conversion accuracy of the ad converter the conversion accuracy of the ad converter differs between mask rom and flash products, as shown below. when developing your application system, careful consideration must be given to these accuracy differences. (v ss = 0.0 v, 4.5 v v dd 5.5 v, topr = ?40 to 85 c) parameter condition min typ. max unit non-linearity error v dd = a vdd / v aref = 5.0 v v ss = 0.0 v ? ? 89cm42 89ch42 89fm42 89fh42 lsb 4 3 zero-point error ? ? 4 3 full-scale error ? ? 4 3 total error ? ? 4 3 (v ss = 0.0 v, 2.7 v v dd < 4.5 v, topr = ?40 to 85 c) parameter condition min typ. max unit non-linearity error v dd = a vdd / v aref = 2.7 v v ss = 0.0 v ? ? 89cm42 89ch42 89fm42 89fh42 lsb 4 3 zero-point error ? ? 4 3 full-scale error ? ? 4 3 total error ? ? 4 3 (v ss = 0.0 v, 2.2 v v dd < 2.7 v, topr = ?40 to 85 c) parameter condition min typ. max unit non-linearity error v dd = a vdd / v aref = 2.2 v v ss = 0.0 v ? ? 89cm42 89ch42 89fm42 89fh42 lsb 5 4 zero-point error ? ? 5 4 full-scale error ? ? 5 4 total error ? ? 5 4 tmp89ch42
precaution for using the emulation chip (development tool) ? precaution for debugging the voltage detection circuit in debug using the rte870/c1 in-circuit emulator (ice mode) with the tmp89c900 mounted on it, no interrupt is generated when the supply voltage rises to the detection voltage. since the #!undefined!# may operate differently, take account of this difference when debugging programs. for detail, refer to the chapter of voltage detection circuit. tmp89ch42
revision history date revision 2008/2/16 1 first release 2008/9/4 2 contents revised 2009/7/16 3 contents revised

table of contents considerations for using both mask rom and flash products tmp89ch42 1.1 features ...................................................................................................................................... 1 1.2 pin assignment .......................................................................................................................... 3 1.3 block diagram ........................................................................................................................... 4 1.4 pin names and functions .......................................................................................................... 5 2. cpu core 2.1 configuration ............................................................................................................................. 9 2.2 memory space ............................................................................................................................ 9 2.2.1 code area ............................................................................................................................................................................. 9 2.2.1.1 ram 2.2.1.2 maskrom 2.2.2 data area ............................................................................................................................................................................ 12 2.2.2.1 sfr 2.2.2.2 ram 2.2.2.3 maskrom 2.3 system clock controller ........................................................................................................... 14 2.3.1 configuration ..................................................................................................................................................................... 14 2.3.2 control ............................................................................................................................................................................... 14 2.3.3 functions ............................................................................................................................................................................16 2.3.3.1 clock generator 2.3.3.2 clock gear 2.3.3.3 timing generator 2.3.4 warm-up counter ............................................................................................................................................................... 19 2.3.4.1 warm-up counter operation when the oscillation is enabled by the hardware 2.3.4.2 warm-up counter operation when the oscillation is enabled by the software 2.3.5 operation mode control circuit .......................................................................................................................................... 21 2.3.5.1 single-clock mode 2.3.5.2 dual-clock mode 2.3.5.3 stop mode 2.3.5.4 transition of operation modes 2.3.6 operation mode control .................................................................................................................................................... 26 2.3.6.1 stop mode 2.3.6.2 idle1/2 and sleep1 modes 2.3.6.3 idle0 and sleep0 modes 2.3.6.4 slow mode 2.4 reset control circuit ............................................................................................................... 37 2.4.1 configuration ..................................................................................................................................................................... 37 2.4.2 control ............................................................................................................................................................................... 37 2.4.3 functions ............................................................................................................................................................................39 2.4.4 reset signal generating factors ........................................................................................................................................ 41 2.4.4.1 power-on reset 2.4.4.2 external reset input (reset pin input) 2.4.4.3 voltage detection reset 2.4.4.4 watchdog timer reset 2.4.4.5 system clock reset 2.4.4.6 trimming data reset 2.4.4.7 internal factor reset detection status register 2.4.4.8 how to use the external reset input pin as a port i
2.5 revision history ...................................................................................................................... 45 3. interrupt control circuit 3.1 configuration ........................................................................................................................... 48 3.2 interrupt latches (il25 to il3) ................................................................................................49 3.3 interrupt enable register (eir) ............................................................................................... 50 3.3.1 interrupt master enable flag (imf) .................................................................................................................................... 50 3.3.2 individual interrupt enable flags (ef25 to ef4) ................................................................................................................ 50 3.4 maskable interrupt priority change function ......................................................................... 53 3.5 interrupt sequence ................................................................................................................... 55 3.5.1 initial setting ......................................................................................................................................................................55 3.5.2 interrupt acceptance processing ......................................................................................................................................... 55 3.5.3 saving/restoring general-purpose registers ........................................................................................................................ 56 3.5.3.1 using push and pop instructions 3.5.3.2 using data transfer instructions 3.5.3.3 using a register bank to save/restore general-purpose registers 3.5.4 interrupt return ................................................................................................................................................................... 58 3.6 software interrupt (intsw) ....................................................................................................59 3.6.1 address error detection ...................................................................................................................................................... 59 3.6.2 debugging .......................................................................................................................................................................... 59 3.7 undefined instruction interrupt (intundef) ....................................................................... 59 3.8 revision history ...................................................................................................................... 60 4. external interrupt control circuit 4.1 configuration ........................................................................................................................... 61 4.2 control ..................................................................................................................................... 61 4.3 function ................................................................................................................................... 65 4.3.1 low power consumption function ..................................................................................................................................... 66 4.3.2 external interrupt 0 ............................................................................................................................................................ 66 4.3.3 external interrupts 1/2/3 .................................................................................................................................................... 67 4.3.3.1 interrupt request signal generating condition detection function 4.3.3.2 a noise canceller pass signal monitoring function when interrupt request signals are generated 4.3.3.3 noise cancel time selection function 4.3.4 external interrupt 4 ............................................................................................................................................................ 68 4.3.4.1 interrupt request signal generating condition detection function 4.3.4.2 a noise canceller pass signal monitoring function when interrupt request signals are generated 4.3.4.3 noise cancel time selection function 4.3.5 external interrupt 5 ............................................................................................................................................................ 70 5. watchdog timer (wdt) 5.1 configuration ........................................................................................................................... 71 5.2 control ..................................................................................................................................... 72 5.3 functions ..................................................................................................................................74 5.3.1 setting of enabling/disabling the watchdog timer operation ............................................................................................. 74 5.3.2 setting the clear time of the 8-bit up counter .....................................................................................................................74 5.3.3 setting the overflow time of the 8-bit up counter .............................................................................................................. 75 5.3.4 setting an overflow detection signal of the 8-bit up counter ............................................................................................. 75 5.3.5 writing the watchdog timer control codes ......................................................................................................................... 76 5.3.6 reading the 8-bit up counter .............................................................................................................................................. 76 5.3.7 reading the watchdog timer status .................................................................................................................................... 76 ii
6. power-on reset circuit 6.1 configuration ........................................................................................................................... 79 6.2 function ................................................................................................................................... 79 7. voltage detection circuit 7.1 configuration ........................................................................................................................... 81 7.2 control ..................................................................................................................................... 82 7.3 function ................................................................................................................................... 83 7.3.1 enabling/disabling the voltage detection operation ........................................................................................................... 83 7.3.2 selecting the voltage detection operation mode ................................................................................................................ 83 7.3.3 selecting the detection voltage level ................................................................................................................................. 84 7.3.4 voltage detection flag and voltage detection status flag ................................................................................................... 84 7.4 register settings ...................................................................................................................... 86 7.4.1 setting procedure when the operation mode is set to generate intvltd interrupt request signals ................................ 86 7.4.2 setting procedure when the operation mode is set to generate voltage detection reset signals ......................................... 86 7.5 revision history ...................................................................................................................... 88 8. i/o ports 8.1 i/o port control registers ....................................................................................................... 91 8.2 list of i/o port settings ........................................................................................................... 92 8.3 i/o port registers .................................................................................................................... 95 8.3.1 port p0 (p03 to p00) .......................................................................................................................................................... 95 8.3.2 port p1 (p13 to p10) .......................................................................................................................................................... 99 8.3.3 port p2 (p27 to p20) ........................................................................................................................................................ 103 8.3.4 port p4 (p47 to p40) ........................................................................................................................................................ 107 8.3.5 port p7 (p77 to p70) ........................................................................................................................................................ 110 8.3.6 port p8 (p81 to p80) ........................................................................................................................................................ 112 8.3.7 port p9 (p91 to p90) ........................................................................................................................................................ 115 8.3.8 port pb (pb7 to pb4) ...................................................................................................................................................... 118 8.4 serial interface selecting function ........................................................................................ 121 8.5 revision history .................................................................................................................... 124 9. special function registers 9.1 sfr1 (0x0000 to 0x003f) ..................................................................................................... 125 9.2 sfr2 (0x0f00 to 0x0fff) .....................................................................................................126 9.3 sfr3 (0x0e40 to 0x0eff) .................................................................................................... 128 10. low power consumption function for peripherals 10.1 control ................................................................................................................................. 132 11. divider output ( dvo ) iii
11.1 configuration .......................................................................................................................135 11.2 control ................................................................................................................................. 136 11.3 function ............................................................................................................................... 137 11.4 revision history .................................................................................................................. 138 12. time base timer (tbt) 12.1 time base timer ................................................................................................................. 139 12.1.1 configuration ................................................................................................................................................................. 139 12.1.2 control ........................................................................................................................................................................... 139 12.1.3 functions ........................................................................................................................................................................140 12.2 revision history .................................................................................................................. 142 13. 16-bit timer counter (tca) 13.1 configuration ....................................................................................................................... 144 13.2 control ................................................................................................................................. 145 13.3 low power consumption function ..................................................................................... 150 13.4 timer function .................................................................................................................... 151 13.4.1 timer mode .................................................................................................................................................................... 151 13.4.1.1 setting 13.4.1.2 operation 13.4.1.3 auto capture 13.4.1.4 register buffer configuration 13.4.2 external trigger timer mode ........................................................................................................................................... 155 13.4.2.1 setting 13.4.2.2 operation 13.4.2.3 auto capture 13.4.2.4 register buffer configuration 13.4.3 event counter mode ....................................................................................................................................................... 157 13.4.3.1 setting 13.4.3.2 operation 13.4.3.3 auto capture 13.4.3.4 register buffer configuration 13.4.4 window mode ................................................................................................................................................................ 159 13.4.4.1 setting 13.4.4.2 operation 13.4.4.3 auto capture 13.4.4.4 register buffer configuration 13.4.5 pulse width measurement mode .................................................................................................................................... 161 13.4.5.1 setting 13.4.5.2 operation 13.4.5.3 capture process 13.4.6 programmable pulse generate (ppg) mode ................................................................................................................... 164 13.4.6.1 setting 13.4.6.2 operation 13.4.6.3 register buffer configuration 13.5 noise canceller ....................................................................................................................167 13.5.1 setting ............................................................................................................................................................................ 167 13.6 revision history .................................................................................................................. 168 14. 8-bit timer counter (tc0) 14.1 configuration ....................................................................................................................... 170 14.2 control ................................................................................................................................. 171 14.2.1 timer counter 00 ............................................................................................................................................................171 14.2.2 timer counter 01 ............................................................................................................................................................173 14.2.3 common to timer counters 00 and 01 ............................................................................................................................175 iv
14.2.4 operation modes and usable source clocks ................................................................................................................... 177 14.3 low power consumption function ..................................................................................... 178 14.4 functions ..............................................................................................................................179 14.4.1 8-bit timer mode .............................................................................................................................................................179 14.4.1.1 setting 14.4.1.2 operation 14.4.1.3 double buffer 14.4.2 8-bit event counter mode ............................................................................................................................................... 182 14.4.2.1 setting 14.4.2.2 operation 14.4.2.3 double buffer 14.4.3 8-bit pulse width modulation (pwm) output mode ....................................................................................................... 184 14.4.3.1 setting 14.4.3.2 operations 14.4.3.3 double buffer 14.4.4 8-bit programmable pulse generate (ppg) output mode ............................................................................................... 189 14.4.4.1 setting 14.4.4.2 operation 14.4.4.3 double buffer 14.4.5 16-bit timer mode ...........................................................................................................................................................193 14.4.5.1 setting 14.4.5.2 operations 14.4.5.3 double buffer 14.4.6 16-bit event counter mode ............................................................................................................................................. 197 14.4.6.1 setting 14.4.6.2 operations 14.4.6.3 double buffer 14.4.7 12-bit pulse width modulation (pwm) output mode ..................................................................................................... 199 14.4.7.1 setting 14.4.7.2 operations 14.4.7.3 double buffer 14.4.8 16-bit programmable pulse generate (ppg) output mode ............................................................................................. 205 14.4.8.1 setting 14.4.8.2 operations 14.4.8.3 double buffer 14.5 revision history .................................................................................................................. 209 15. real time clock (rtc) 15.1 configuration ....................................................................................................................... 211 15.2 control ................................................................................................................................. 211 15.3 function ............................................................................................................................... 212 15.3.1 low power consumption function ............................................................................................................................... 212 15.3.2 enabling/disabling the real time clock operation .......................................................................................................... 212 15.3.3 selecting the interrupt generation interval ..................................................................................................................... 212 15.4 real time clock operation ................................................................................................. 213 15.4.1 enabling the real time clock operation .......................................................................................................................... 213 15.4.2 disabling the real time clock operation ......................................................................................................................... 213 16. asynchronous serial interface (uart) 16.1 configuration ....................................................................................................................... 216 16.2 control ................................................................................................................................. 217 16.3 low power consumption function ..................................................................................... 221 16.4 protection to prevent uart0cr1 and uart0cr2 registers from being changed ....... 222 16.5 activation of stop, idle0 or sleep0 mode ................................................................... 223 16.5.1 transition of register status ............................................................................................................................................223 16.5.2 transition of txd pin status ......................................................................................................................................... 223 16.6 transfer data format ........................................................................................................... 224 16.7 infrared data format transfer mode .................................................................................. 224 v
16.8 transfer baud rate .............................................................................................................. 225 16.8.1 transfer baud rate calculation method ...........................................................................................................................226 16.8.1.1 bit width adjustment using uart0cr2 16.8.1.2 calculation of set values of uart0cr2 and uart0dr 16.9 data sampling method ........................................................................................................ 229 16.10 received data noise rejection ......................................................................................... 231 16.11 transmit/receive operation .............................................................................................. 232 16.11.1 data transmit operation ................................................................................................................................................232 16.11.2 data receive operation ................................................................................................................................................. 232 16.12 status flag ......................................................................................................................... 233 16.12.1 parity error ................................................................................................................................................................... 233 16.12.2 framing error .............................................................................................................................................................. 234 16.12.3 overrun error ............................................................................................................................................................... 235 16.12.4 receive data buffer full ............................................................................................................................................. 238 16.12.5 transmit busy flag ...................................................................................................................................................... 239 16.12.6 transmit buffer full .................................................................................................................................................... 239 16.13 receiving process .............................................................................................................. 240 16.14 ac properties .....................................................................................................................242 16.14.1 irda properties ............................................................................................................................................................ 242 16.15 revision history ................................................................................................................ 243 17. synchronous serial interface (sio) 17.1 configuration ....................................................................................................................... 246 17.2 control ................................................................................................................................. 247 17.3 low power consumption function ..................................................................................... 250 17.4 functions ..............................................................................................................................251 17.4.1 transfer format .............................................................................................................................................................. 251 17.4.2 serial clock .................................................................................................................................................................... 251 17.4.3 transfer edge selection .................................................................................................................................................. 251 17.5 transfer modes .................................................................................................................... 253 17.5.1 8-bit transmit mode ........................................................................................................................................................ 253 17.5.1.1 setting 17.5.1.2 starting the transmit operation 17.5.1.3 transmit buffer and shift operation 17.5.1.4 operation on completion of transmission 17.5.1.5 stopping the transmit operation 17.5.2 8-bit receive mode ........................................................................................................................................................258 17.5.2.1 setting 17.5.2.2 starting the receive operation 17.5.2.3 operation on completion of reception 17.5.2.4 stopping the receive operation 17.5.3 8-bit transmit/receive mode ........................................................................................................................................... 262 17.5.3.1 setting 17.5.3.2 starting the transmit/receive operation 17.5.3.3 transmit buffer and shift operation 17.5.3.4 operation on completion of transmission/reception 17.5.3.5 stopping the transmit/receive operation 17.6 ac characteristics ............................................................................................................... 267 17.7 revision history .................................................................................................................. 268 18. serial bus interface (sbi) 18.1 communication format ....................................................................................................... 270 18.1.1 i2c bus ........................................................................................................................................................................... 270 18.1.2 free data format ............................................................................................................................................................. 271 18.2 configuration ....................................................................................................................... 272 18.3 control ................................................................................................................................. 273 vi
18.4 functions ..............................................................................................................................276 18.4.1 low power consumption function ............................................................................................................................... 276 18.4.2 selecting the slave address match detection and the general call detection .......................................................276 18.4.3 selecting the number of clocks for data transfer and selecting the acknowledgement or non-acknowledgment mode ...... 276 18.4.3.1 number of clocks for data transfer 18.4.3.2 output of an acknowledge signal 18.4.4 serial clock .................................................................................................................................................................... 278 18.4.4.1 clock source 18.4.4.2 clock synchronization 18.4.5 master/slave selection .................................................................................................................................................... 280 18.4.6 transmitter/receiver selection ........................................................................................................................................280 18.4.7 start/stop condition generation ...................................................................................................................................... 280 18.4.8 interrupt service request and release .............................................................................................................................. 281 18.4.9 setting of serial bus interface mode ............................................................................................................................... 282 18.4.10 software reset .............................................................................................................................................................. 282 18.4.11 arbitration lost detection monitor ................................................................................................................................282 18.4.12 slave address match detection monitor ....................................................................................................................... 284 18.4.13 general call detection monitor .......................................................................................................................... 284 18.4.14 last received bit monitor ............................................................................................................................................. 285 18.4.15 slave address and address recognition mode specification ......................................................................................... 285 18.5 data transfer of i2c bus ..................................................................................................... 286 18.5.1 device initialization ....................................................................................................................................................... 286 18.5.2 start condition and slave address generation ................................................................................................................. 286 18.5.3 1-word data transfer ....................................................................................................................................................... 287 18.5.3.1 when sbi0sr2 is "1" (master mode) 18.5.3.2 when sbi0sr2 is "0" (slave mode) 18.5.4 stop condition generation .............................................................................................................................................. 290 18.5.5 restart ............................................................................................................................................................................ 291 18.6 ac specifications ................................................................................................................ 293 18.7 revision history .................................................................................................................. 295 19. key-on wakeup (kwu) 19.1 configuration ....................................................................................................................... 297 19.2 control ................................................................................................................................. 298 19.3 functions ..............................................................................................................................299 20. 10-bit ad converter (adc) 20.1 configuration ....................................................................................................................... 301 20.2 control ................................................................................................................................. 302 20.3 functions .............................................................................................................................306 20.3.1 single mode ................................................................................................................................................................... 306 20.3.2 repeat mode .................................................................................................................................................................. 306 20.3.3 ad operation disable and forced stop of ad operation ................................................................................................ 307 20.4 register setting ................................................................................................................... 308 20.5 starting stop/idle0/slow modes ................................................................................. 308 20.6 analog input voltage and ad conversion result .............................................................. 309 20.7 precautions about the ad converter ................................................................................... 310 20.7.1 analog input pin voltage range ...................................................................................................................................... 310 20.7.2 analog input pins used as input/output ports .................................................................................................................310 20.7.3 noise countermeasure .................................................................................................................................................... 310 20.8 revision history .................................................................................................................. 311 vii
21. input/output circuit 21.1 control pins ......................................................................................................................... 313 22. electrical characteristics 22.1 absolute maximum ratings ............................................................................................... 315 22.2 operating conditions ........................................................................................................... 316 22.3 dc characteristics .............................................................................................................. 317 22.4 ad conversion characteristics .......................................................................................... 318 22.5 power-on reset circuit characteristics ............................................................................... 319 22.6 voltage detecting circuit characteristics ........................................................................... 320 22.7 ac characteristics ............................................................................................................... 321 22.8 oscillating condition ........................................................................................................... 322 22.9 handling precaution ............................................................................................................ 323 22.10 revision history ................................................................................................................ 324 23. package dimensions viii
cmos 8-bit microcontroller tmp89ch42 the tmp89ch42 is a single-chip 8-bit high-speed and high-functionality microcomputer incorporating 16384 bytes of mask rom. product no. rom (mask rom) ram package flash mcu emulation chip TMP89CH42UG 16384 bytes 2048 bytes lqfp44-p-1010-0.80b tmp89fh42ug * tmp89c900xbg note : * ; under development 1.1 features 1. 8-bit single chip microcomputer tlcs-870/c1 series - instruction execution time : 100 ns (at 10 mhz) 122 s (at 32.768 khz) - 133 types & 732 basic instructions 2. 25 interrupt sources (external : 6 internal : 19 , except reset) 3. input / output ports (40 pins) note : two of above pins can not be used for the i/o port, because they should be connected with the high frequency osc input. - large current output: 8 pins (typ. 20ma) 4. watchdog timer - interrupt or reset can be selected by the program. 5. power-on reset circuit 6. voltage detection circuit 7. divider output function 8. time base timer 9. 16-bit timer counter (tca) : 2 ch - timer, external trigger, event counter, window, pulse width measurement, ppg output modes 10. 8-bit timer counter (tc0) : 4 ch - timer, event counter, pwm, ppg output modes - usable as a 16-bit timer, 12-bit pwm output and 16-bit ppg output by the cascade connection of two channels. 11. real time clock 12. uart : 1ch 13. uart/sio : 1ch note : one sio channel can be used at the same time. 14. i 2 c/sio : 1ch 15. key-on wake-up : 8 ch 16. 10-bit successive approximation type ad converter - analog input : 8ch 17. clock operation mode control circuit : 2 circuit single clock mode / dual clock mode 18. low power consumption operation (8 mode) tmp89ch42 page 1 ra000
- stop mode: oscillation stops. (battery/capacitor back-up.) - slow1 mode: low power consumption operation using low-frequency clock.(high-frequency clock stop.) - slow2 mode: low power consumption operation using low-frequency clock.(high-frequency clock oscillate.) - idle0 mode: cpu stops, and only the time-based-timer(tbt) on peripherals operate using high frequency clock. released when the reference time set to tbt has elapsed. - idle1 mode: the cpu stops, and peripherals operate using high frequency clock. release by interruputs(cpu restarts). - idle2 mode: cpu stops and peripherals operate using high and low frequency clock. release by interruputs. (cpu restarts). - sleep0 mode: cpu stops, and only the time-based-timer(tbt) on peripherals operate using low frequency clock. released when the reference time set to tbt has elapsed. - sleep1 mode: cpu stops, and peripherals operate using low frequency clock. release by interruput.(cpu restarts). 19. wide operation voltage: 4.3 v to 5.5 v at 10mhz /32.768 khz 2.7 v to 5.5 v at 4.2 mhz /32.768 khz 2.2 v to 5.5 v at 2mhz /32.768 khz tmp89ch42 1.1 features page 2 ra000
1.2 pin assignment p90 (txd1/rxd1) p77 (int4) p76 (int3) p75 (int2) p74 ( dvo) p47 (ain7/kwi7) p46 (ain6/kwi6) p45 (ain5/kwi5) p44 (ain4/kwi4) p43 (ain3/kwi3) p42 (ain2/kwi2) (txd1/rxd1) p91 p41 (ain1/kwi1) ( pwm02/ ppg02/tc02) p80 p40 (ain0/kwi0) ( pwm03/ ppg03/tc03) p81 varef/avdd ( pwm00/ ppg00/tc00) p70 p27 ( pwm01/ ppg01/tc01) p71 p26 ( ppga0/tca0) p72 p25 (sclk0) ( ppga1/tca1) p73 p24 (scl0/si0) (so0/rxd0/txd0) pb4 p23 (sda0/so0) (si0/txd0/rxd0) pb5 p22 (sclk0) (sclk0) pb6 p21 (rxd0/txd0/si0) pb7 p20 (txd0/rxd0/so0) vss (xin) p00 (xout) p01 mode vdd (xtin) p02 (xtout) p03 ( reset) p10 ( stop/ int5) p11 ( int0) p12 (int1) p13 figure 1-1 pin assignment tmp89ch42 page 3 ra000
1.3 block diagram figure 1-2 block diagram tmp89ch42 1.3 block diagram page 4 ra000
1.4 pin names and functions table 1-1 pin names and functions (1/3) pin name input/output functions p03 xtout io o port03 low frequency osc output p02 xtin io i port02 low frequency osc input p01 xout io o port01 high frequency osc output p00 xin io i port00 high frequency osc input p13 int1 io i port13 external interrupt 1 input p12 int0 io i port12 external interrupt 0 input p11 int5 stop io i i port11 external interrupt 5 input stop mode release input p10 reset io i port10 reset signal input p27 io port27 p26 io port26 p25 sclk0 io io port25 serial clock input/output 0 p24 scl0 si0 io io i port24 i2c bus clock input/output 0 serial data input 0 p23 sda0 so0 io io o port23 i2c bus data input/output 0 serial data output 0 p22 sclk0 io io port22 serial clock input/output 0 p21 rxd0 txd0 si0 io i o i port21 uart data input 0 uart data output 0 serial data input 0 p20 txd0 rxd0 so0 io o i o port20 uart data output 0 uart data input 0 serial data output 0 tmp89ch42 page 5 ra000
table 1-2 pin names and functions (2/3) pin name input/output functions p47 ain7 kwi7 io i i port47 analog input 7 key-on wake-up input 7 p46 ain6 kwi6 io i i port46 analog input 6 key-on wake-up input 6 p45 ain5 kwi5 io i i port45 analog input 5 key-on wake-up input 5 p44 ain4 kwi4 io i i port44 analog input 4 key-on wake-up input 4 p43 ain3 kwi3 io i i port43 analog input 3 key-on wake-up input 3 p42 ain2 kwi2 io i i port42 analog input 2 key-on wake-up input 2 p41 ain1 kwi1 io i i port41 analog input 1 key-on wake-up input 1 p40 ain0 kwi0 io i i port40 analog input 0 key-on wake-up input 0 p77 int4 io i port77 external interrupt 4 input p76 int3 io i port76 external interrupt 3 input p75 int2 io i port75 external interrupt 2 input p74 dvo io o port74 divider output p73 tca1 ppga1 io i o port73 tca1 input ppga1 output p72 tca0 ppga0 io i o port72 tca0 input ppga0 output p71 tc01 ppg01 pwm01 io i o o port71 tc01 input ppg01 output pwm01 output tmp89ch42 1.4 pin names and functions page 6 ra000
table 1-2 pin names and functions (3/3) pin name input/output functions p70 tc00 ppg00 pwm00 io i o o port70 tc00 input ppg00 output pwm00 output p81 tc03 ppg03 pwm03 io i o o port81 tc03 input ppg03 output pwm03 output p80 tc02 ppg02 pwm02 io i o o port80 tc02 input ppg02 output pwm02 output p91 rxd1 txd1 io i o port91 uart data input 1 uart data output 1 p90 txd1 rxd1 io o i port90 uart data output 1 uart data input 1 pb7 io portb7 pb6 sclk0 io io portb6 serial clock input/output 0 pb5 rxd0 txd0 si0 io i o i portb5 uart data input 0 uart data output 0 serial data input 0 pb4 txd0 rxd0 so0 io o i o portb4 uart data output 0 uart data input 0 serial data output 0 mode i test pin for out-going test (fix to low level). varef / avdd i analog reference voltage input pin for a/d conversion. / an- alog power supply pin. vdd i vdd pin vss i gnd pin tmp89ch42 page 7 ra000
tmp89ch42 1.4 pin names and functions page 8 ra000
2. cpu core 2.1 configuration the cpu core consists of a cpu, a system clock controller and a reset circuit. this chapter describes the cpu core address space, the system clock controller and the reset circuit. 2.2 memory space the 870/c1 cpu memory space consists of a code area to be accessed as instruction operation codes and operands and a data area to be accessed as sources and destinations of transfer and calculation instructions. both the code and data areas have independent 64-kbyte address spaces. 2.2.1 code area the code area stores operation codes, operands, vector tables for vector call instructions and interrupt vector tables. the ram and the maskrom are mapped in the code area. 0x0000 swi instruction (0xff) is fetched. 0x003f 0x0040 ram (2048 bytes) 0x083f swi instruction (0xff) is fetched. swi instruction (0xff) is fetched. 0xbfff 0xc000 mask rom (16384 bytes) mask rom (16384 bytes) 0xffa0 vector table for vec- tor call instructions (32 bytes) vector table for vec- tor call instructions (32 bytes) 0xffbf 0xffcc interrupt vector table (52 bytes) interrupt vector table (52 bytes) 0xffff immediately after re- set release when the ram is mapped in the code area figure 2-1 memory map in the code area tmp89ch42 page 9 rb000
2.2.1.1 ram the ram is mapped in the data area immediately after reset release. by setting syscr3 to "1" and writing 0xd4 to syscr4, ram can be mapped to 0x0040to 0x083f in the code area to execute the program. at this time, by setting syscr to "1" and writing 0xd4 to syscr4, vector table for vector call instructions and interrupt except reset can be mapped to ram. note 1: when the ram is not mapped in the code area, the swi instruction is fetched from 0x0040 to 0x 083f. note2: the contents of the ram become unstable when the power is turned on and immediately after a reset is released. to execute the program by using the ram, transfer the program to be executed in the initialization routine. system control register 3 syscr3 (0x0fde) 7 6 5 4 3 2 1 0 bit symbol - - - - - rvctr rarea (rstdis) read/write r r r r r r/w r/w r/w after reset 0 0 0 0 0 0 0 0 rarea specifies mapping of the ram in the code area 0 : the ram is not mapped from 0x0040 to 0x083f in the code area. 1 : the ram is mapped from 0x0040 to 0x083f in the code area. rvctr specifies mapping of the vector ta- ble for vector call instructions and interrupts vector table for vector call instruc- tions vector table for interrupt 0 : 0xffa0 to 0xffbf in the code area 0xffcc to 0xffff in the code area 1 : 0x01a0 to 0x01bf in the code area 0x01cc to 0x01fd in the code area note 1: the value of syscr3 is invalid until 0xd4 is written into syscr4. note 2: to assign vector address areas to ram, set syscr3 to "1" and syscr3 to "1". note 3: bits 7 to 3 of syscr3 are read as "0". system control register 4 syscr4 (0x0fdf) 7 6 5 4 3 2 1 0 bit symbol syscr4 read/write w after reset 0 0 0 0 0 0 0 0 syscr4 writes the syscr3 data control code. 0xb2 : 0xd4 : 0x71 : enables the contents of syscr3. enables the contents of syscr3 and syscr3 . enables the contents of irstsr others : invalid note 1: syscr4 is a write-only register, and must not be accessed by using a read-modify-write instruction, such as a bit oper- ation. note 2: after syscr3 is modified, syscr4 should be written 0xb2 (enable code for syscr3) in normal mode when fcgck is fc/4 (cgcr=00). otherwise, syscr3 may be enabled at unexpected tim- ing. note 3: after irstsr is modified, syscr4 should be written 0x71 (enable code for irstsr in normal mode when fcgck is fc/4 (cgcr=00). otherwise, irstsr may be enabled at unexpected timing. tmp89ch42 2. cpu core 2.2 memory space page 10 rb000
system control status register 4 syssr4 (0x0fdf) 7 6 5 4 3 2 1 0 bit symbol - - - - - rvctrs rareas (rstdis) read/write r r r r r r r r after reset 0 0 0 0 0 0 0 0 rareas status of mapping of the ram in the code area 0 : 1 : the enabled syscr3 data is "0". the enabled syscr3 data is "1". rvctrs status of mapping of the vector ad- dress in the area 0 : 1 : the enabled syscr3 data is "0". the enabled syscr3 data is "1". note:bits 7 to 3 of syssr4 are read as "0". example: program transfer (transfer the program saved in the data area to the ram.) ld hl, transfer_start_address ; destination ram address ld de, program_start_address ; source rom address ld bc, byte_of_program ; number of bytes of the program to be executed -1 trans_ram: ld a, (de) ; reading the program to be transferred ld (hl), a ; writing the program to be transferred inc hl ; destination address increment inc de ; source address increment dec bc ; have all the programs been transferred? j f, trans_ram 2.2.1.2 maskrom the maskrom is mapped to 0xc000 to 0xffff in the code area after reset release. tmp89ch42 page 11 rb000
2.2.2 data area the data area stores the data to be accessed as sources and destinations of transfer and calculation instructions. the sfr, the ram and maskrom are mapped in the data area. 0x0000 sfr1 (64 bytes) 0x003f 0x0040 ram (2048 bytes) 0x083f 0xff is read 0x0e40 sfr3 (192 bytes) 0x0eff 0x0f00 sfr2 (256 bytes) 0x0fff 0x1000 0xff is read 0xbfff 0xc000 mask rom (16384 bytes) 0xffff figure 2-2 memory map in the data area 2.2.2.1 sfr the sfr is mapped to 0x0000 to 0x003f (sfr1), 0x0f00 to 0x0fff (sfr2) and 0x0e40 to 0x0eff (sfr3) in the data area after reset release. note:don't access the reserved sfr. 2.2.2.2 ram the ram is mapped to 0x0040 to 0x083f in the data area after reset release. note: the contents of the ram become unstable when the power is turned on and immediately after a reset is released. to execute the program by using the ram, transfer the program to be executed in the initialization routine. tmp89ch42 2. cpu core 2.2 memory space page 12 rb000
example: ram initialization program ld hl, ram_top_address ; head of address of the ram to be initialized ld a, 0x00 ; initialization data ld bc, byte_of_clear_bytes ; number of bytes of ram to be initialized -1 clr_ram: ld (hl), a ; initialization of the ram inc hl ; initialization address increment dec bc ; have all the rams been initialized? j f, clr_ram 2.2.2.3 maskrom the maskrom is mapped to 0xc000 to 0xffff in the data area after reset release. tmp89ch42 page 13 rb000
2.3 system clock controller 2.3.1 configuration the system clock controller consists of a clock generator, a clock gear, a timing generator, a warm-up counter and an operation mode control circuit. figure 2-3 system clock controller 2.3.2 control the system clock controller is controlled by system control register 1 (syscr1), system control register 2 (syscr2), the warm-up counter control register (wuccr), the warm-up counter data register (wucdr) and the clock gear control register (cgcr). system control register 1 syscr1 (0x0fdc) 7 6 5 4 3 2 1 0 bit symbol stop relm outen dv9ck - - - - read/write r/w r/w r/w r/w r r r r after reset 0 0 0 0 1 0 0 0 stop activates the stop mode 0 : 1 : operate the cpu and the peripheral circuits stop the cpu and the peripheral circuits (activate the stop mode) relm selects the stop mode release method 0 : edge-sensitive release mode (release the stop mode at the rising edge of the stop mode release signal) 1 : level-sensitive release mode (release the stop mode at the "h" level of the stop mode release signal) outen selects the port output state in the stop mode 0 : 1 : high impedance output hold dv9ck selects the input clock to stage 9 of the divider 0 : 1 : fcgck/2 9 fs/4 note 1: fcgck: gear clock [hz], fs: low-frequency clock [hz] note 2: bits 2, 1 and 0 of syscr1 are read as "0". bit 3 is read as "1". tmp89ch42 2. cpu core 2.3 system clock controller page 14 rb000 high-frequency clock oscillation circuit clock gear ( 1/4, 1/2, 1) warm-up counter fcgck dv9ck fcgcksel intwuc interrupt request xen/xten stop system clock oscillation/stop control clock generator xin xout xtin xtout fc fs 1/4 timing generator operation mode control circuit syscr1 tbtcr cgcr syscr2 wuccr wucdr low-frequency clock oscillation circuit
note 3: if the stop mode is activated with syscr1 set at "0", the port internal input is fixed to "0". therefore, an external interrupt may be set at the falling edge, depending on the pin state when the stop mode is activated. note 4: the p11 pin is also used as the stop pin. when the stop mode is activated, the pin reverts to high impedance state and is put in input mode, regardless of the state of syscr1. note 5: writing of the second byte data will be executed improperly if the operation is switched to the stop state by an instruction, such as ldw, which executes 2-byte data transfer at a time. note 6: don't set sysck1 to "1" before the oscillation of the low-frequency clock oscillation circuit becomes stable. note 7: in the slow1/2 or sleep1 mode, fs/4 is input to stage 9 of the divider, regardless of the state of syscr1< dv9ck >. system control register 2 syscr2 (0x0fdd) 7 6 5 4 3 2 1 0 bit symbol - xen xten sysck idle tghalt - - read/write r r/w r/w r/w r/w r/w r r after reset 0 1 0 0 0 0 0 0 xen controls the high-frequency clock oscillation circuit 0 : 1 : stop oscillation continue or start oscillation xten controls the low-frequency clock os- cillation circuit 0 : 1 : stop oscillation continue or start oscillation sysck selects a system clock 0 : 1 : gear clock (fcgck) (normal1/2 or idle1/2 mode) low-frequency clock (fs/4) (slow1/2 or sleep1 mode) idle cpu and wdt control (idle1/2 or sleep1 mode) 0 : 1 : operate the cpu and the wdt stop the cpu and the wdt (activate idle1/2 or sleep1 mode) tghalt tg control (idle0 or sleep0 mode) 0 : 1 : enable the clock supply from the tg to all the peripheral circuits disable the clock supply from the tg to the peripheral circuits except the tbt (activate idle0 or sleep0 mode) note 1: fcgck: gear clock [hz], fs: low-frequency clock [hz] note 2: wdt: watchdog timer, tg: timing generator note 3: don't set both syscr2 and syscr2 to "1" simultaneously. note 4: writing of the second byte data will be executed improperly if the operation is switched to the idle state by an instruction, such as ldw, which executes 2-byte data transfer at a time. note 5: when the idle1/2 or sleep1 mode is released, syscr2 is cleared to "0" automatically. note 6: when the idle0 or sleep0 mode is released, syscr2 is cleared to "0" automatically. note 7: bits 7, 1 and 0 of syscr2 are read as "0". warm-up counter control register wuccr (0x0fcd) 7 6 5 4 3 2 1 0 bit symbol wucrst - - - wucdiv wucsel - read/write w r r r r/w r/w r after reset 0 0 0 0 1 1 0 1 wucrst resets and stops the warm-up coun- ter 0 : 1 : - clear and stop the counter wucdiv selects the frequency division of the warm-up counter source clock 00 : 01 : 10 : 11 : source clock source clock / 2 source clock / 2 2 source clock / 2 3 wucsel selects the warm-up counter source clock 0 : 1 : select the high-frequency clock (fc) select the low-frequency clock (fs) note 1: fc: high-frequency clock [hz], fs: low-frequency clock [hz] note 2: wuccr is cleared to "0" automatically, and need not be cleared to "0" after being set to "1". note 3: bits 7 to 4 of wuccr are read as "0". bit 0 is read as "1". tmp89ch42 page 15 rb000
note 4: before starting the warm-up counter operation, set the source clock and the frequency division rate at wuccr and set the warm-up time at wucdr. warm-up counter data register wucdr (0x0fce) 7 6 5 4 3 2 1 0 bit symbol wucdr read/write r/w after reset 0 1 1 0 0 1 1 0 wucdr warm-up time setting note 1: don't start the warm-up counter operation with wucdr set at "0x00". clock gear control register cgcr (0x0fcf) 7 6 5 4 3 2 1 0 bit symbol - - - - - - fcgcksel read/write r r r r r r r/w after reset 0 0 0 0 0 0 0 0 fcgcksel clock gear setting 00 : 01 : 10 : 11 : fcgck = fc / 4 fcgck = fc / 2 fcgck = fc reserved note 1: fcgck: gear clock [hz], fc: high-frequency clock [hz] note 2: don't change cgcr in the slow mode. note 3: bits 7 to 2 of cgcr are read as "0". 2.3.3 functions 2.3.3.1 clock generator the clock generator generates the basic clock for the system clocks to be supplied to the cpu core and peripheral circuits. it contains two oscillation circuits: one for the high-frequency clock and the other for the low-frequency clock. the oscillation circuit pins are also used as ports p0. for the setting to use them as ports, refer to the chapter of i/o ports. to use ports p00 and p01 as the high-frequency clock oscillation circuits (the xin and xout pins), set p0fc0 to "1" and then set syscr2 to "1". to use ports p02 and p03 as the low-frequency clock oscillation circuits (the xtin and xtout pins), set p0fc2 to "1" and then set syscr2 to "1". the high-frequency (fc) clock and the low-frequency (fs) clock can easily be obtained by connecting an oscillator between the xin and xout pins and between the xtin and xtout pins respectively. clock input from an external oscillator is also possible. in this case, external clocks are applied to the xin/ xtin pins and the xout/xtout pins are kept open. tmp89ch42 2. cpu core 2.3 system clock controller page 16 rb000
enabling/disabling the oscillation of the high-frequency clock oscillation circuit and the low-frequency clock oscillation circuit and switching the pin function to ports are controlled by the software and hardware. the software control is executed by syscr2, syscr2 and the p0 port function control register p0fc. the hardware control is executed by reset release and the operation mode control circuit when the operation is switched to the stop mode as described in "2.3.5 operation mode control circuit". note: no hardware function is available for external direct monitoring of the basic clock. the oscillation fre- quency can be adjusted by programming the system to output pulses at a certain frequency to a port (for example, a clock output) with interrupts disabled and the watchdog timer disabled and monitoring the output. an adjustment program must be created in advance for a system that requires adjustment of the oscillation frequency. to prevent the dead lock of the cpu core due to the software-controlled enabling/disabling of the oscil- lation, an internal factor reset is generated depending on the combination of values of the clock selected as the main system clock, syscr2, syscr2 and the p0 port function control register p0fc0. table 2-1 prohibited combinations of oscillation enable register conditions p0fc0 syscr2 syscr2 syscr2 state don't care 0 0 dont care all the oscillation circuits are stopped. dont care dont care 0 1 the low-frequency clock (fs) is selected as the main system clock, but the low-frequency clock oscillation circuit is stop- ped. dont care 0 dont care 0 the high-frequency clock (fc) is selected as the main system clock, but the high-frequency clock oscillation circuit is stop- ped. 0 1 dont care dont care the high-frequency clock oscillation circuit is allowed to os- cillate, but the port is set as a general-purpose port. note: it takes a certain period of time after syscr2 is changed before the main system clock is switched. if the currently operating oscillation circuit is stopped before the main system clock is switch- ed, the internal condition becomes as shown in table 2-1 and a system clock reset occurs. for details of clock switching, refer to "2.3.6 operation mode control". figure 2-4 examples of oscillator connection 2.3.3.2 clock gear the clock gear is a circuit that selects a gear clock (fcgck) obtained by dividing the high-frequency clock (fc) and inputs it to the timing generator. selects a divided clock at cgcr. two machine cycles are needed after cgcr is changed before the gear clock (fcgck) is changed. tmp89ch42 page 17 rb000 xin high-frequency clock xout (a) crystal or ceramic oscillator xin xout (b) external oscillator (open) xtin low-frequency clock xtout (c) crystal oscillator xtin xtout (d) external oscillator (open)
the gear clock (fcgck) may be longer than the set clock width, immediately after cgcr is changed. immediately after reset release, the gear clock (fcgck) becomes the clock that is a quarter of the high- frequency clock (fc). table 2-2 gear clock (fcgck) cgcr fcgck 00 fc / 4 01 fc / 2 10 fc 11 reserved note: don't change cgcr in the slow mode. this may stop the gear clock (fcgck) from being changed. 2.3.3.3 timing generator the timing generator is a circuit that generates system clocks to be supplied to the cpu core and the peripheral circuits, from the gear clock (fcgck) or the clock that is a quarter of the low-frequency clock (fs). the timing generator has the following functions: 1. generation of the main system clock (fm) 2. generation of clocks for the timer counter, the time base timer and other peripheral circuits figure 2-5 configuration of timing generator (1) configuration of timing generator the timing generator consists of a main system clock generator, a prescaler, a 21-stage divider and a machine cycle counter. 1. main system clock generator this circuit selects the gear clock (fcgck) or the clock that is a quarter of the low-frequency clock (fs) for the main system clock (fm) to operate the cpu core. clearing syscr2 to "0" selects the gear clock (fcgck). setting it to "1" selects the clock that is a quarter of the low-frequency clock (fs). tmp89ch42 2. cpu core 2.3 system clock controller page 18 rb000 main system clock generator machine cycle counter syscr2 syscr1 gear clock fcgck prescaler divider multiplexer a timer counter, time base timer and other peripheral circuits divider b s y main system clock fm a quarter of the basic clock for the low-frequency clock
it takes a certain period of time after syscr2 is changed before the main system clock is switched. if the currently operating oscillation circuit is stopped before the main system clock is switched, the internal condition becomes as shown in table 2-1 and a system clock reset occurs. for details of clock switching, refer to "2.3.6 operation mode control". 2. prescaler and divider these circuits divide fcgck. the divided clocks are supplied to the timer counter, the time base timer and other peripheral circuits. when both syscr1 and syscr2 are "0", the input clock to stage 9 of the divider becomes the output of stage 8 of the divider. when syscr1 or syscr2 is "1", the input clock to stage 9 of the divider becomes fs/4. when syscr2 is "1", the outputs of stages 1 to 8 of the divider and prescaler are stopped. the prescaler and divider are cleared to "0" at a reset and at the end of the warm-up operation that follows the release of stop mode. 3. machine cycle instruction execution is synchronized with the main system clock (fm). the minimum instruction execution unit is called a "machine cycle". one machine cycle corresponds to one main system clock. there are a total of 11 different types of instructions for the tlcs-870/c1 series: 10 types ranging from 1-cycle instructions, which require one machine cycle for execution, to 10-cycle instructions, which require 10 machine cycles for execution, and 13-cycle instructions, which require 13 machine cycles for execution. 2.3.4 warm-up counter the warm-up counter is a circuit that counts the high-frequency clock (fc) and the low-frequency clock (fs), and it consists of a source clock selection circuit, a 3-stage frequency division circuit and a 14-stage counter. the warm-up counter is used to secure the time after a power-on reset is released before the supply voltage becomes stable and secure the time after the stop mode is released or the operation mode is changed before the oscillation by the oscillation circuit becomes stable. figure 2-6 warm-up counter circuit tmp89ch42 page 19 rb000 s z d c b a s z a b clock for high-frequency clock oscillation circuit (fc) clock for low-frequency clock oscillation circuit (fs) com- parator wucdr syscr2 syscr1 wuccr enable/disable counting up xen xten stop intwuc interrupt enable cpu operation wucsel wucdiv wucrst warm-up counter controller 1 2 3 4 5 6 7 8 9 10 11 12 13 14 0 1 2 3 4 5 6 7 1 2 3
2.3.4.1 warm-up counter operation when the oscillation is enabled by the hardware (1) when a power-on reset is released or a reset is released the warm-up counter serves to secure the time after a power-on reset is released before the supply voltage becomes stable and the time after a reset is released before the oscillation by the high-frequency clock oscillation circuit becomes stable. when the power is turned on and the supply voltage exceeds the power-on reset release voltage, the warm-up counter reset signal is released. at this time, the cpu and the peripheral circuits are held in the reset state. a reset signal initializes wuccr to "0" and wuccr to "11", which se- lects the high-frequency clock (fc) as the input clock to the warm-up counter. when a reset is released for the warm-up counter, the high-frequency clock (fc) is input to the warm- up counter, and the 14-stage counter starts counting the high-frequency clock (fc). when the upper 8 bits of the warm-up counter become equal to wucdr, counting is stopped and a reset is released for the cpu and the peripheral circuits. wucdr is initialized to 0x66 after reset release, which makes the warm-up time 0x66 2 9 /fc[s]. note: the clock output from the oscillation circuit is used as the input clock to the warm-up counter. the warm-up time contains errors because the oscillation frequency is unstable until the oscil- lation circuit becomes stable. (2) when the stop mode is released the warm-up counter serves to secure the time after the oscillation is enabled by the hardware before the oscillation becomes stable at the release of the stop mode. the high-frequency clock (fc) or the low-frequency clock (fs), which generates the main system clock when the stop mode is activated, is selected as the input clock for frequency division circuit, regardless of wuccr. before the stop mode is activated, select the division rate of the input clock to the warm-up counter at wuccr and set the warm-up time at wucdr. when the stop mode is released, the 14-stage counter starts counting the input clock selected in the frequency division circuit. when the upper 8 bits of the warm-up counter become equal to wucdr, counting is stopped and the operation is restarted by an instruction that follows the stop mode activation instruction. clock that generates the main system clock when the stop mode is activated wuccr wuccr counter input clock warm-up time fc dont care 00 fc 2 6 / fc to 255 x 2 6 / fc 01 fc / 2 2 7 / fc to 255 x 2 7 / fc 10 fc / 2 2 2 8 / fc to 255 x 2 8 / fc 11 fc / 2 3 2 9 / fc to 255 x 2 9 / fc fs don't care 00 fs 2 6 / fs to 255 x 2 6 / fs 01 fs / 2 2 7 / fs to 255 x 2 7 / fs 10 fs / 2 2 2 8 / fs to 255 x 2 8 / fs 11 fs / 2 3 2 9 / fs to 255 x 2 9 / fs note 1: when the operation is switched to the stop mode during the warm-up for the oscillation enabled by the software, the warm-up counter holds the value at the time, and restarts counting after the stop mode is released. in this case, the warm-up time at the release of the stop mode becomes insufficient. don't switch the operation to the stop mode during the warm-up for the oscillation enabled by the software. tmp89ch42 2. cpu core 2.3 system clock controller page 20 rb000
note 2: the clock output from the oscillation circuit is used as the input clock to the warm-up counter. the warm-up time contains errors because the oscillation frequency is unstable until the oscillation circuit becomes stable. set the sufficient time for the oscillation start property of the oscillator. 2.3.4.2 warm-up counter operation when the oscillation is enabled by the software the warm-up counter serves to secure the time after the oscillation is enabled by the software before the oscillation becomes stable, at a mode change from normal1 to normal2 or from slow1 to slow2. select the input clock to the frequency division circuit at wuccr. select the input clock to the 14-stage counter at wuccr. after the warm-up time is set at wucdr, setting syscr2 or syscr2 to "1" allows the stopped oscillation circuit to start oscillation and the 14-stage counter to start counting the selected input clock. when the upper 8 bits of the counter become equal to wucdr, an intwuc interrupt occurs, counting is stopped and the counter is cleared. set wuccr to "1" to discontinue the warm-up operation. by setting it to "1", the count-up operation is stopped, the warm-up counter is cleared, and wuccr is cleared to "0". syscr2 and syscr2 hold the values when wuccr is set to "1". to restart the warm-up operation, syscr2 or syscr2 must be cleared to "0". note:the warm-up counter starts counting when syscr2 or syscr2 is changed from "0" to "1". the counter will not start counting by writing "1" to syscr2 or syscr2 when it is in the state of "1". wuccr wuccr counter input clock warm-up time 0 00 fc 2 6 / fc to 255 x 2 6 / fc 01 fc / 2 2 7 / fc to 255 x 2 7 / fc 10 fc / 2 2 2 8 / fc to 255 x 2 8 / fc 11 fc / 2 3 2 9 / fc to 255 x 2 9 / fc 1 00 fs 2 6 / fs to 255 x 2 6 / fs 01 fs / 2 2 7 / fs to 255 x 2 7 / fs 10 fs / 2 2 2 8 / fs to 255 x 2 8 / fs 11 fs / 2 3 2 9 / fs to 255 x 2 9 / fs note: the clock output from the oscillation circuit is used as the input clock to the warm-up counter. the warm-up time contains errors because the oscillation frequency is unstable until the oscillation circuit becomes stable. set the sufficient time for the oscillation start property of the oscillator. 2.3.5 operation mode control circuit the operation mode control circuit starts and stops the oscillation circuits for the high-frequency and low- frequency clocks, and switches the main system clock (fm). there are three operating modes: the single-clock mode, the dual-clock mode and the stop mode. these modes are controlled by the system control registers (syscr1 and syscr2). figure 2-7 shows the operating mode transition diagram. tmp89ch42 page 21 rb000
2.3.5.1 single-clock mode only the gear clock (fcgck) is used for the operation in the single-clock mode. the main system clock (fm) is generated from the gear clock (fcgck). therefore, the machine cycle time is 1/fcgck [s]. the gear clock (fcgck) is generated from the high-frequency clock (fc). in the single-clock mode, the low-frequency clock generation circuit pins p02 (xtin) and p03 (xtout) can be used as the i/o ports. (1) normal1 mode in this mode, the cpu core and the peripheral circuits operate using the gear clock (fcgck). the normal1 mode becomes active after reset release. (2) idle1 mode in this mode, the cpu and the watchdog timer stop and the peripheral circuits operate using the gear clock (fcgck). the idle1 mode is activated by setting syscr2 to "1" in the normal1 mode. when the idle1 mode is activated, the cpu and the watchdog timer stop. when the interrupt latch enabled by the interrupt enable register efr becomes "1", the idle1 mode is released to the normal1 mode. when the imf (interrupt master enable flag) is "1" (interrupts enabled), the operation returns normal after the interrupt processing is completed. when the imf is "0" (interrupts disabled), the operation is restarted by the instruction that follows the idle1 mode activation instruction. (3) idle0 mode in this mode, the cpu and the peripheral circuits stop, except the oscillation circuits and the time base timer. in the idle0 mode, the peripheral circuits stop in the states when the idle0 mode is activated or become the same as the states when a reset is released. for operations of the peripheral circuits in the idle0 mode, refer to the section of each peripheral circuit. the idle0 mode is activated by setting syscr2 to "1" in the normal1 mode. when the idle0 mode is activated, the cpu stops and the timing generator stops the clock supply to the peripheral circuits except the time base timer. when the falling edge of the source clock selected at tbtcr is detected, the idle0 mode is released, the timing generator starts the clock supply to all the peripheral circuits and the normal1 mode is restored. note that the idle0 mode is activated and restarted, regardless of the setting of tbtcr. when the idle0 mode is activated with tbtcr set at "1", the inttbt interrupt latch is set after the normal mode is restored. when the imf is "1" and the ef5 (the individual interrupt enable flag for the time base timer) is "1", the operation returns normal after the interrupt processing is completed. tmp89ch42 2. cpu core 2.3 system clock controller page 22 rb000
when the imf is "0" or when the imf is "1" and the ef5 (the individual interrupt enable flag for the time base timer) is "0", the operation is restarted by the instruction that follows the idle0 mode acti- vation instruction. 2.3.5.2 dual-clock mode the gear clock (fcgck) and the low-frequency clock (fs) are used for the operation in the dual-clock mode. the main system clock (fm) is generated from the gear clock (fcgck) in the normal2 or idle2 mode, and generated from the clock that is a quarter of the low-frequency clock (fs) in the slow1/2 or sleep0/1 mode. therefore, the machine cycle time is 1/fcgck [s] in the normal2 or idle2 mode and is 4/fs [s] in the slow1/2 or sleep0/1 mode. p02 (xtin) and p03 (xtout) are used as the low-frequency clock oscillation circuit pins. (these pins cannot be used as i/o ports in the dual-clock mode.) the operation of the tlcs-870/c1 series becomes the single-clock mode after reset release. to operate it in the dual-clock mode, allow the low-frequency clock to oscillate at the beginning of the program. (1) normal2 mode in this mode, the cpu core operates using the gear clock (fcgck), and the peripheral circuits operate using the gear clock (fcgck) or the clock that is a quarter of the low-frequency clock (fs). (2) slow2 mode in this mode, the cpu core and the peripheral circuits operate using the clock that is a quarter of the low-frequency clock (fs). in the slow mode, some peripheral circuits become the same as the states when a reset is released. for operations of the peripheral circuits in the slow mode, refer to the section of each peripheral circuit. set syscr2 to switch the operation mode from normal2 to slow2 or from slow2 to normal2. in the slow2 mode, outputs of the prescaler and stages 1 to 8 of the divider stop. (3) slow1 mode in this mode, the high-frequency clock oscillation circuit stops operation and the cpu core and the peripheral circuits operate using the clock that is a quarter of the low-frequency clock (fs). this mode requires less power to operate the high-frequency clock oscillation circuit than in the slow2 mode. in the slow mode, some peripheral circuits become the same as the states when a reset is released. for operations of the peripheral circuits in the slow mode, refer to the section of each peripheral circuit. set syscr2 to switch the operation between the slow1 and slow2 modes. in the slow1 or sleep1 mode, outputs of the prescaler and stages 1 to 8 of the divider stop. (4) idle2 mode in this mode, the cpu and the watchdog timer stop and the peripheral circuits operate using the gear clock (fcgck) or the clock that is a quarter of the low-frequency clock (fs). tmp89ch42 page 23 rb000
the idle2 mode can be activated and released in the same way as for the idle1 mode. the operation returns to the normal2 mode after this mode is released. (5) sleep1 mode in this mode, the high-frequency clock oscillation circuit stops operation, the cpu and the watchdog timer stop, and the peripheral circuits operate using the clock that is a quarter of the low-frequency clock (fs). in the sleep1 mode, some peripheral circuits become the same as the states when a reset is released. for operations of the peripheral circuits in the sleep1 mode, refer to the section of each peripheral circuit. the sleep1 mode can be activated and released in the same way as for the idle1 mode. the operation returns to the slow1 mode after this mode is released. in the slow1 or sleep1 mode, outputs of the prescaler and stages 1 to 8 of the divider stop. (6) sleep0 mode in this mode, the high-frequency clock oscillation circuit stops operation, the time base timer operates using the clock that is a quarter of the low-frequency clock (fs), and the core and the peripheral circuits stop. in the sleep0 mode, the peripheral circuits stop in the states when the sleep0 mode is activated or become the same as the states when a reset is released. for operations of the peripheral circuits in the sleep0 mode, refer to the section of each peripheral circuit. the sleep0 mode can be activated and released in the same way as for the idle0 mode. the operation returns to the slow1 mode after this mode is released. in the sleep0 mode, the cpu stops and the timing generator stops the clock supply to the peripheral circuits except the time base timer. 2.3.5.3 stop mode in this mode, all the operations in the system, including the oscillation circuits, are stopped and the internal states in effect before the system was stopped are held with low power consumption. in the stop mode, the peripheral circuits stop in the states when the stop mode is activated or become the same as the states when a reset is released. for operations of the peripheral circuits in the stop mode, refer to the section of each peripheral circuit. the stop mode is activated by setting syscr1 to "1". the stop mode is released by the stop mode release signals. after the warm-up time has elapsed, the operation returns to the mode that was active before the stop mode, and the operation is restarted by the instruction that follows the stop mode activation instruction. tmp89ch42 2. cpu core 2.3 system clock controller page 24 rb000
2.3.5.4 transition of operation modes note 1: the normal1 and normal2 modes are generically called the normal mode; the slow1 and slow2 modes are called the slow mode; the idle0, idle1 and idle2 modes are called the idle mode; and the sleep0 and sleep1 are called the sleep mode. note 2: the mode is released by the falling edge of the source clock selected at tbtcr. figure 2-7 operation mode transition diagram tmp89ch42 page 25 rb000 idle0 mode reset warm-up that follows reset release normal1 mode stop normal2 mode slow2 mode slow1 mode idle0 mode idle2 mode sleep1 mode sleep0 mode (a) single-clock mode (b) dual-clock mode syscr2 = "1" syscr1 = "1" syscr2 = "1" syscr1 = "1" syscr2 = "1" syscr1 = "1" interrupt interrupt stop mode release signal stop mode release signal stop mode release signal interrupt syscr2 = ?1? syscr2 = "0" syscr2 = "1" syscr2 = "0" syscr2 = "1" syscr2 = "0" syscr2 = "1" reset release warm-up completed syscr2 = "1" (note 2) (note 2)
table 2-3 operation modes and conditions operation mode oscillation circuit cpu core watchdog timer time base timer ad converter other periph- eral circuits machine cy- cle time high-fre- quency low-fre- quency single clock reset oscillation stop reset reset reset reset reset 1 / fcgck [s] normal1 operate operate operate operate operate idle1 stop stop idle0 stop stop stop stop stop ? dual clock normal2 oscillation oscillation operate with the high fre- quency operate with the high / low frequency operate operate operate 1 / fcgck [s] idle2 stop stop slow2 operate with the low fre- quency operate with the low fre- quency stop 4/ fs [s] slow1 stop operate with the low fre- quency operate with the low fre- quency sleep1 stop stop sleep0 stop stop stop stop ? 2.3.6 operation mode control 2.3.6.1 stop mode the stop mode is controlled by system control register 1 (syscr1) and the stop mode release signals. (1) start the stop mode the stop mode is started by setting syscr1 to "1". in the stop mode, the following states are maintained: 1. both the high-frequency and low-frequency clock oscillation circuits stop oscillation and all internal operations are stopped. 2. the data memory, the registers and the program status word are all held in the states in effect before stop mode was started. the port output latch is determined by the value of syscr1. 3. the prescaler and the divider of the timing generator are cleared to "0". 4. the program counter holds the address of the instruction 2 ahead of the instruction (e.g., [set (syscr1).7]) which started the stop mode. (2) release the stop mode the stop mode is released by the following stop mode release signals. it is also released by a reset by the reset pin, a power-on reset and a reset by the voltage detection circuits. when a reset is released, the warm-up starts. after the warm-up is completed, the normal1 mode becomes active. 1. release by the stop pin 2. release by key-on wakeup 3. release by the voltage detection circuits tmp89ch42 2. cpu core 2.3 system clock controller page 26 rb000
note: during the stop period (from the start of the stop mode to the end of the warm-up), due to changes in the external interrupt pin signal, interrupt latches may be set to "1" and interrupts may be accepted immediately after the stop mode is released. before starting the stop mode, therefore, disable interrupts. also, before enabling interrupts after stop mode is released, clear unnecessary interrupt latches. 1. release by the stop pin release the stop mode by using the stop pin. the stop mode release by the stop pin includes the level-sensitive release mode and the edge-sensitive release mode, either of which can be selected at syscr1. the stop pin is also used as the p11 port and the int5 (external interrupt input 5) pin. - level-sensitive release mode the stop mode is released by setting the stop pin high. setting syscr1 to "1" selects the level-sensitive release mode. this mode is used for the capacitor backup when the main power supply is cut off and the long term battery backup. even if an instruction for starting the stop mode is executed while the stop pin input is high, the stop mode does not start. thus, to start the stop mode in the level-sensitive release mode, it is necessary for the program to first confirm that the stop pin input is low. this can be confirmed by testing the port by the software or using interrupts note: when the stop mode is released, the warm-up counter source clock automatically changes to the clock that generated the main system clock when the stop mode was started, regard- less of wuccr. example: starting the stop mode from normal mode after testing p00 port. (warm-up time at release of the stop mode is about 300s at fc= 10mhz.) ld (syscr1), 0x40 ; sets up the level-sensitive release mode sstoph: test (p0prd). 5 ; wait until stop pin becomes l level. j f, sstoph ld (wuccr), 0x01 ; wuccr = 00 (no division) (note) ld (wucdr),0x2f ; sets the warm-up time ; 300s / 6.4s = 46.9 round up to 0x2f di ; imf = 0 set (syscr1).7 ; starts the stop mode note: when the stop mode is released, the warm-up counter source clock automatically changes to the clock that generated the main system clock when the stop mode was started, regardless of wuccr. example: starting the stop mode from the slow mode with an int5 interrupt (warm-up time at release of the stop mode is about 450ms at fs=32.768 khz.) pint5: test (p0prd).5 ; to reject noise, the stop mode does not start j f, sint5 ; if the stop pin input is high. ld (syscr1), 0x40 ; sets up the level-sensitive release mode ld (wuccr), 0x03 ; wuccr = 00 (no division) (note) ld (wucdr),0xe8 ; sets the warm-up time ; 450 ms/1.953 ms = 230.4 round up to 0xe8 di ; imf = 0 set (syscr1).7 ; starts the stop mode sint5: reti tmp89ch42 page 27 rb000
note: when the stop mode is released, the warm-up counter source clock automatically changes to the clock that generated the main system clock when the stop mode was started, regardless of wuccr. note: even if the stop pin input returns to low after the warm-up starts, the stop mode is not restarted. figure 2-8 level-sensitive release mode (example when the high-frequency clock oscillation circuit is selected) - edge-sensitive release mode in this mode, the stop mode is released at the rising edge of the stop pin input. setting syscr1 to "0" selects the edge-sensitive release mode. this is used in applications where a relatively short program is executed repeatedly at periodic intervals. this periodic signal (for example, a clock from a low-power con- sumption oscillator) is input to the stop pin. in the edge-sensitive release mode, the stop mode is started even when the stop pin input is high example: starting the stop mode from the normal mode (warm-up time at release of the stop mode is about 200s at fc=10 mhz.) ld (wuccr),0x01 ; wuccr = 00 (no division) (note) ld (wucdr),0x20 ; sets the warm-up time ; 200s / 6.4s = 31.25 round up to 0x20 di ; imf = 0 ld (syscr1) , 0x80 ; starts the stop mode with the edge-sensitive release mode selected note: when the stop mode is released, the warm-up counter source clock automatically changes to the clock that generated the main system clock when the stop mode was started, regardless of wuccr. note: if the rising edge is input to the stop pin within 1 machine cycle after syscr1 is set to "1", the stop mode will not be released. figure 2-9 edge-sensitive release mode (example when the high-frequency clock oscillation circuit is selected) 2. release by the key-on wakeup tmp89ch42 2. cpu core 2.3 system clock controller page 28 rb000 stop pin xout pin normal mode v ih warm-up stop mode stop mode the stop mode is started by the program. the stop mode is released by the hardware at the rising edge of the stop pin input. normal mode stop pin xout pin normal mode the stop mode is released by the hardware. normal mode v ih warm-up stop mode confirm by program that the stop pin input is low and start the stop mode. always released if the stop pin input is high.
the stop mode is released by inputting the prescribed level to the key-on wakeup pin. the level to release the stop mode can be selected from "h" and "l". for release by the key-on wakeup, refer to section "key-on wakeup". note: if the key-on wakeup pin input becomes the opposite level to the release level after the warm-up starts, the stop mode is not restarted. 3. release by the voltage detection circuits the stop mode is released by the supply voltage detection by the voltage detection circuits. if the voltage detection operation mode of the voltage detection circuits is set to "generates a voltage detection reset signal", the stop mode is released and a reset is applied as soon as the supply voltage becomes lower than the detection voltage. when the supply voltage becomes equal to or higher than the detection voltage of the voltage detection circuits, the reset is released and the warm-up starts. after the warm-up is completed, the normal1 mode becomes active. for details, refer to the section of the voltage detection circuits. note: if the supply voltage becomes equal to or higher than the detection voltage within 1 ma- chine cycle after syscr1 is set to "1", the stop mode will not be released. (3) stop mode release operation the stop mode is released in the following sequence: 1. oscillation starts. for the oscillation start operation in each mode, refer to "table 2-4 oscil- lation start operation at release of the stop mode". 2. warm-up is executed to secure the time required to stabilize oscillation. the internal operations remain stopped during warm-up. the warm-up time is set by the warm-up counter, depending on the oscillator characteristics. 3. after the warm-up time has elapsed, the normal operation is restarted by the instruction that follows the stop mode start instruction. at this time, the prescaler and the divider of the timing generator are cleared to "0". note: when the stop mode is released with a low hold voltage, the following cautions must be ob- served. the supply voltage must be at the operating voltage level before releasing the stop mode. the reset pin input must also be "h" level, rising together with the supply voltage. in this case, if an external time constant circuit has been connected, the reset pin input voltage will increase at a slower pace than the power supply voltage. at this time, there is a danger that a reset may occur if the input voltage level of the reset pin drops below the non-inverting high-level input voltage (hysteresis input). table 2-4 oscillation start operation at release of the stop mode operation mode before the stop mode is started high-frequency clock low-frequency clock oscillation start operation after release single-clock mode normal1 high-frequency clock oscillation cir- cuit - the high-frequency clock oscillation circuit starts os- cillation. the low-frequency clock oscillation circuit stops os- cillation. dual-clock mode normal2 high-frequency clock oscillation cir- cuit low-frequency clock oscillation cir- cuit the high-frequency clock oscillation circuit starts os- cillation. the low-frequency clock oscillation circuit starts os- cillation. slow1 - low-frequency clock oscillation cir- cuit the high-frequency clock oscillation circuit stops os- cillation. the low-frequency clock oscillation circuit starts os- cillation. tmp89ch42 page 29 rb000
note: when the operation returns to the normal2 mode, fc is input to the frequency division circuit of the warm-up counter. 2.3.6.2 idle1/2 and sleep1 modes the idle1/2 and sleep1 modes are controlled by the system control register 2 (syscr2) and maskable interrupts. the following states are maintained during these modes. 1. the cpu and the watchdog timer stop their operations. the peripheral circuits continue to operate. 2. the data memory, the registers, the program status word and the port output latches are all held in the status in effect before idle1/2 or sleep1 mode was started. 3. the program counter holds the address of the instruction 2 ahead of the instruction which starts the idle1/2 or sleep1 mode. figure 2-10 idle1/2 and sleep 1 modes tmp89ch42 2. cpu core 2.3 system clock controller page 30 rb000 cpu and wdt stop interrupt processing reset yes no no no no imf = "1" reset input yes yes (interrupt release mode) (normal release mode) interrupt request starting idle1/2 mode or sleep1 mode by an instruction execution of the instruction which follows the idle1/2 mode or sleep1 mode start instruction
(1) start the idle1/2 and sleep1 modes after the interrupt master enable flag (imf) is set to "0", set the individual interrupt enable flag (ef) to "1", which releases idle1/2 and sleep1 modes. to start the idle1/2 or sleep1 mode, set syscr2 to "1". if the release condition is satisfied when it is attempted to start the idle1/2 or sleep1 mode, syscr2 remains cleared and the idle1/2 or sleep1 mode will not be started. note 1: when a watchdog timer interrupt is generated immediately before the idle1/2 or sleep1 mode is started, the watchdog timer interrupt will be processed but the idle1/2 or sleep1 mode will not be started. note 2: before starting the idle1/2 or sleep1 mode, enable the interrupt request signals to be generated to release the idle1/2 or sleep1 mode and set the individual interrupt enable flag. (2) release the idle1/2 and sleep1 modes the idle1/2 and sleep1 modes include a normal release mode and an interrupt release mode. these modes are selected at the interrupt master enable flag (imf). after releasing idle1/2 or sleep1 mode, syscr2 is automatically cleared to "0" and the operation mode is returned to the mode pre- ceding the idle1/2 or sleep1 mode. the idle1/2 and sleep1 modes are also released by a reset by the reset pin , a power-on reset and a reset by the voltage detection circuits. after releasing the reset, the warm-up starts. after the warm-up is completed, the normal1 mode becomes active. ? normal release mode (imf = "0") the idle1/2 or sleep1 mode is released when the interrupt latch enabled by the individual interrupt enable flag (ef) is "1". the operation is restarted by the instruction that follows the idle1/2 or sleep1 mode start instruction. normally, the interrupt latch (il) of the interrupt source used for releasing must be cleared to "0" by load instructions. ? interrupt release mode (imf = "1") the idle1/2 or sleep1 mode is released when the interrupt latch enabled by the individual interrupt enable flag (ef) is "1". after the interrupt is processed, the operation is restarted by the instruction that follows the idle1/2 or sleep1 mode start instruction. 2.3.6.3 idle0 and sleep0 modes the idle0 and sleep0 modes are controlled by the system control register 2 (syscr2) and the time base timer control register (tbtcr). the following states are maintained during the idle0 and sleep0 modes: ? the timing generator stops the clock supply to the peripheral circuits except the time base timer. ? the data memory, the registers, the program status word and the port output latches are all held in the states in effect before the idle0 or sleep0 mode was started. ? the program counter holds the address of the instruction 2 ahead of the instruction which starts the idle0 or sleep0 mode. tmp89ch42 page 31 rb000
figure 2-11 idle0 and sleep0 modes ? start the idle0 and sleep0 modes stop (disable) the peripherals such as a timer counter. to start the idle0 or sleep0 mode, set syscr2 to "1". ? release the idle0 and sleep0 modes the idle0 and sleep0 modes include a normal release mode and an interrupt release mode. these modes are selected at the interrupt master enable flag (imf), the individual interrupt enable flag (ef5) for the time base timer and tbtcr. after releasing the idle0 or sleep0 mode, syscr2 is automatically cleared to "0" and the operation mode is returned to the mode preceding the idle0 or sleep0 mode. if tbtcr has been set at "1", the inttbt interrupt latch is set. the idle0 and sleep0 modes are also released by a reset by the reset pin , a power-on reset and a reset by the voltage detection circuits. when a reset is released, the warm-up starts. after the warm-up is completed, the normal1 mode becomes active. tmp89ch42 2. cpu core 2.3 system clock controller page 32 rb000 reset yes no no "0" yes yes (interrupt release mode) (normal release mode) yes "1" no no stopping peripherals by instructions cpu and wdt stop interrupt processing reset input tbt source clock falling edge tbtcr tbt interrupt enabled imf = "1" starting idle0 or sleep0 mode by an instruction execution of the instruction which follows the idle0 or sleep0 mode start instruction
(1) normal release mode (imf, ef5, tbtcr = "0") the idle0 or sleep0 mode is released when the falling edge of the source clock selected at tbtcr is detected. after the idle0 or sleep0 mode is released, the operation is restarted by the instruction that follows the idle0 or sleep0 mode start instruction. when tbtcr is "1", the time base timer interrupt latch is set. (2) interrupt release mode (imf, ef5, tbtcr = "1") the idle0 or sleep0 mode is released when the falling edge of the source clock selected at tbtcr is detected. after the release, the inttbt interrupt processing is started. note 1: the idle0 or sleep0 mode is released to the normal1 or slow1 mode by the asynchronous internal clock selected at tbtcr. therefore, the period from the start to the release of the mode may be shorter than the time specified at tbtcr. note 2: when a watchdog timer interrupt is generated immediately before the idle0 or sleep0 mode is started, the watchdog timer interrupt will be processed but the idle0 or sleep0 mode will not be started. 2.3.6.4 slow mode the slow mode is controlled by system control register 2 (syscr2). (1) switching from the normal2 mode to the slow1 mode set syscr2 to "1". when a maximum of 2/fcgck + 10/fs [s] has elapsed since syscr2 is set to "1", the main system clock (fm) is switched to fs/4. after switching, wait for 2 machine cycles or longer, and then clear syscr2 to "0" to turn off the high-frequency clock oscillator. if the oscillation of the low-frequency clock (fs) is unstable, confirm the stable oscillation at the warm- up counter before implementing the procedure described above. note 1: be sure to follow this procedure to switch the operation from the normal2 mode to the slow1 mode. note 2: it is also possible to allow the basic clock for the high-frequency clock to oscillate continuously to return to normal2 mode. however, be sure to turn off the oscillation of the basic clock for the high-frequency clock when the stop mode is started from the slow mode. note 3: after switching syscr2, be sure to wait for 2 machine cycles or longer before clearing syscr2 to "0". clearing it within 2 machine cycles causes a system clock reset. note 4: when the main system clock (fm) is switched, the gear clock (fcgck) is synchronized with the clock that is a quarter of the basic clock (fs) for the low-frequency clock. for the synchronization, fm is stopped for a period of 10/fs or shorter. tmp89ch42 page 33 rb000
figure 2-12 switching of the main system clock (fm) (switching from fcgck to fs/4) example 1: switching from the normal2 mode to the slow1 mode (when fc is used as the basic clock for the high- frequency clock) set (syscr2).4 ; syscr2 = 1 ; (switches the main system clock to the basic clock for the ; low-frequency clock for the slow2 mode) nop ; waits for 2 machine cycles nop clr (syscr2).6 ; syscr2 = 0 ; (turns off the high-frequency clock oscillation circuit) example 2: switching to the slow1 mode after the stable oscillation of the low-frequency clock oscillation circuit is confirmed at the warm-up counter (fs=32.768khz, warm-up time = about 100 ms) ; #### initialize routine #### set (p0fc).2 ; p0fc2 = 1 (uses p02/03 as oscillators) | | ld (wuccr), 0x02 ; wuccr = 00 (no division) ; wuccr = 1 (selects fs as the source clock) ld (wucdr), 0x33 ; sets the warm-up time ; (determines the time depending on the oscillator characteristics) ; 100 ms/1.95 ms = 51.2 round up to 0x33 set (eirl).4 ; enables intwuc interrupts set (syscr2).5 ; syscr2 = 1 ; (starts the low-frequency clock oscillation and starts the warm-up ; counter) | ; #### interrupt service routine of warm-up counter interrupts #### pintwuc: set (syscr2).4 ; syscr2 = 1 ; (switches the main system clock to the low-frequency clock) nop ; waits for 2 machine cycles nop clr (syscr2).6 ; syscr2 = 0 ; (turns off the high-frequency clock oscillation circuit) reti | tmp89ch42 2. cpu core 2.3 system clock controller page 34 rb000 gear clock (fcgck) when the rising edge of fcgck is detected twice after syscr2 is changed from 0 to 1, f is stopped for synchronization. when the rising edge of fs/4 is detected twice after fm is stopped, fm is switched to fs. quarter of the low-frequency clock (fs/4) main system clock syscr2 10/fs (max.)
vintwuc: dw pintwuc ; intwuc vector table (2) switching from the slow1 mode to the normal1 mode set syscr2 to "1" to enable the high-frequency clock (fc) to oscillate. confirm at the warm- up counter that the oscillation of the basic clock for the high-frequency clock has stabilized, and then clear syscr2 to "0". when a maximum of 8/fs + 2.5/fcgck [s] has elapsed since syscr2 is cleared to "0", the main system clock (fm) is switched to fcgck. after switching, wait for 2 machine cycles or longer, and then clear syscr2 to "0" to turn off the low-frequency clock oscillator. the slow mode is also released by a reset by the reset pin , a power-on reset and a reset by the voltage detection circuits. when a reset is released, the warm-up starts. after the warm-up is completed, the normal1 mode becomes active. note 1: be sure to follow this procedure to switch the operation from the slow1 mode to the normal1 mode. note 2: after switching syscr2, be sure to wait for 2 machine cycles or longer before clearing syscr2 to "0". clearing it within 2 machine cycles causes a system clock reset. note 3: when the main system clock (fm) is switched, the gear clock (fcgck) is synchronized with the clock that is a quarter of the basic clock (fs) for the low-frequency clock. for the synchronization, fm is stopped for a period of 2.5/fcgck [s] or shorter. note 4: when p0fc0 is "0", setting syscr2 to "1" causes a system clock reset. note 5: when syscr2 is set at "1", writing "1" to syscr2 does not cause the warm-up counter to start counting the source clock. figure 2-13 switching the main system clock (fm) (switching from fs/4 to fcgck) example : switching from the slow1 mode to the normal1 mode after the stability of the high-frequency clock oscillation circuit is confirmed at the warm-up counter (fc = 10 mhz, warm-up time = 4.0 ms) ; #### initialize routine #### set (p0fc).2 ; p0fc2 = 1 (uses p02/03 as oscillators) | | ld (wuccr), 0x09 ; wuccr = 10 (divided by 2) ; wuccr = 0 (selects fc as the source clock) ld (wucdr), 0x9d ; sets the warm-up time ; (determine the time depending on the frequency and the oscillator ; characteristics) ; 4ms / 25.6us = 156.25 round up to 0x9d tmp89ch42 page 35 rb000 gear clock (fcgck) when the rising edge of fs/4 is detected twice after syscr2 is changed from 1 to 0, f is stopped for synchronization. when the rising edge of fcgck is detected twice after fm is stopped, fm is switched to fcgck. quarter of the low-frequency clock (fs/4) main system clock syscr2 2.5/fcgck(max.)
set (eirl). 4 ; enables intwuc interrupts set (syscr2) .6 ; syscr2 = 1 ; (starts the oscillation of the high-frequency clock oscillation circuit) | ; #### interrupt service routine of warm-up counter interrupts #### pintwuc: clr (syscr2). 4 ; syscr2 = 0 ; (switches the main system clock to the gear clock) nop ; waits for 2 machine cycles nop clr (syscr2). 5 ; syscr2 = 0 ; (turns off the low-frequency clock oscillation circuit) reti | vintwuc: dw pintwuc ; intwuc vector table tmp89ch42 2. cpu core 2.3 system clock controller page 36 rb000
2.4 reset control circuit the reset circuit controls the external and internal factor resets and initializes the system. 2.4.1 configuration the reset control circuit consists of the following reset signal generation circuits: 1. external reset input (external factor) 2. power-on reset (internal factor) 3. voltage detection reset 1 (internal factor) 4. voltage detection reset 2 (internal factor) 5. watchdog timer reset (internal factor) 6. system clock reset (internal factor) 7. trimming data reset (internal factor) figure 2-14 reset control circuit 2.4.2 control the reset control circuit is controlled by system control register 3 (syscr3), system control register 4 (syscr4), system control status register (syssr4) and the internal factor reset detection status register (irstsr). system control register 3 syscr3 (0x0fde) 7 6 5 4 3 2 1 0 bit symbol - - - - - (rvctr) (rarea) rstdis read/write r r r r r r/w r/w r/w after reset 0 0 0 0 0 0 0 0 rstdis external reset input enable register 0 : 1 : enables the external reset input. disables the external reset input. note 1: the enabled syscr3 is initialized by a power-on reset only, and cannot be initialized by an external reset input or internal factor reset. the value written in syscr3 is reset by a power-on reset, external reset input or internal factor reset. note 2: the value of syscr3 is invalid until 0xb2 is written into syscr4. note 3: after syscr3 is modified, syscr4 should be written 0xb2 (enable code for syscr3) in nor- mal1 mode when fcgck is fc/4 (cgcr=00). otherwise, syscr3 may be enabled at unexpec- ted timing. tmp89ch42 page 37 rb000 p10(reset) internal factor reset detection status register, voltage detection circuit reset signal external reset input enable reset signal warm-up counter reset signal system clock control circuit warm-up counter cpu/peripheral circuits reset signal trimming data reset signal system clock reset signal watchdog timer reset signal voltage detection reset 2 signal power-on reset signal p10 port voltage detection reset 1 signal
note 4: bits 7 to 3 of syscr3 are read as "0". system control register 4 syscr4 (0x0fdf) 7 6 5 4 3 2 1 0 bit symbol syscr4 read/write w after reset 0 0 0 0 0 0 0 0 syscr4 writes the syscr3 data control code. 0xb2 : 0xd4 : 0x71 : others : enables the contents of syscr3 enables the contents of syscr3 and syscr3 enables the contents of irstsr invalid note 1: syscr4 is a write-only register, and must not be accessed by using a read-modify-write instruction, such as a bit oper- ation. note 2: after syscr3 is modified, syscr4 should be written 0xb2 (enable code for syscr3) in normal mode when fcgck is fc/4 (cgcr=00). otherwise, syscr3 may be enabled at unexpected tim- ing. note 3: after irstsr is modified, syscr4 should be written 0x71 (enable code for irstsr in normal mode when fcgck is fc/4 (cgcr=00). otherwise, irstsr may be enabled at unexpected timing. system control status register 4 syssr4 (0x0fdf) 7 6 5 4 3 2 1 0 bit symbol - - - - - (rvctrs) (rareas) rstdiss read/write r r r r r r r r after reset 0 0 0 0 0 0 0 0 rstdiss external reset input enable status 0 : 1 : the enabled syscr3 data is "0". the enabled syscr3 data is "1". note 1: the enabled syscr3 is initialized by a power-on reset only, and cannot be initialized by any other reset signals. the value written in syscr3 is reset by a power-on reset and other reset signals. note 2: bits 7 to 3 of syscr4 are read as "0". tmp89ch42 2. cpu core 2.4 reset control circuit page 38 rb000
internal factor reset detection status register irstsr (0x0fcc) 7 6 5 4 3 2 1 0 bit symbol fclr - trmds trmrf lvd2rf lvd1rf sysrf wdtrf read/write w r r r r r r r after reset 0 0 0 0 0 0 0 0 fclr flag initialization control 0 : 1 : - clears the internal factor reset flag to "0". trmds trimming data status 0 : 1 : - detect state of abnormal trimming data trmrf trimming data reset detection flag 0 : 1 : - detects the trimming data reset. lvd2rf voltage detection reset 2 detection flag 0 : 1 : - detects the voltage detection 2 reset. lvd1rf voltage detection reset 1 detection flag 0 : 1 : - detects the voltage detection 1 reset. sysrf system clock reset detection flag 0 : 1 : - detects the system clock reset. wdtrf watchdog timer reset detection flag 0 : 1 : - detects the watchdog timer reset. note 1: internal reset factor flag (irstsr) is initialized only by a power- on reset, an external reset input or irstsr . it is not initialized by an internal factor reset. note 2: care must be taken in system designing since the irstsr may not fulfill its functions due to disturbing noise and other effects. note 3: if syscr4 is set to 0x71 after irstsr is set to "1", internal factor reset flag is cleared to "0" and irstsr is automatically cleared to "0". note 4: after irstsr is modified, syscr4 should be written 0x71 (enable code for irstsr in normal mode when fcgck is fc/4 (cgcr=00). otherwise, irstsr may be enabled at unexpected timing. note 5: bit 7, 6 of irstsr is read as "0". 2.4.3 functions the power-on reset, external reset input and internal factor reset signals are input to the warm-up circuit of the clock generator. during reset, the warm-up counter circuit is reset, and the cpu and the peripheral circuits are reset. after reset is released, the warm-up counter starts counting the high frequency clock (fc), and executes the warm-up operation that follows reset release. during the warm-up operation that follows reset release, the trimming data is loaded from the non-volatile exclusive use memory for adjustment of the ladder resistor that generates the comparison voltage for the power- on reset and the voltage detection circuits. when the warm-up operation that follows reset release is finished, the cpu starts execution of the program from the reset vector address stored in addresses 0xfffe to 0xffff. when a reset signal is input during the warm-up operation that follows reset release, the warm-up counter circuit is reset. the reset operation is common to the power-on reset, external reset input and internal factor resets, except for the initialization of some special function registers and the initialization of the voltage detection circuits. when a reset is applied, the peripheral circuits become the states as shown in table 2-5. tmp89ch42 page 39 rb000
table 2-5 initialization of built-in hardware by reset operation and its status after release built-in hardware during reset during the warm-up opera- tion that follows reset re- lease immediately after the warm-up operation that fol- lows reset release program counter (pc) 0xfffe 0xfffe 0xfffe stack pointer (sp) 0x00ff 0x00ff 0x00ff ram indeterminate indeterminate indeterminate general-purpose registers (w, a, b, c, d, e, h, l, ix and iy) indeterminate indeterminate indeterminate register bank selector (rbs) 0 0 0 jump status flag (jf) indeterminate indeterminate indeterminate zero flag (zf) indeterminate indeterminate indeterminate carry flag (cf) indeterminate indeterminate indeterminate half carry flag (hf) indeterminate indeterminate indeterminate sign flag (sf) indeterminate indeterminate indeterminate overflow flag (vf) indeterminate indeterminate indeterminate interrupt master enable flag (imf) 0 0 0 individual interrupt enable flag (ef) 0 0 0 interrupt latch (il) 0 0 0 high-frequency clock oscillation circuit oscillation enabled oscillation enabled oscillation enabled low-frequency clock oscillation circuit oscillation disabled oscillation disabled oscillation disabled warm-up counter reset start stop timing generator prescaler and divider 0 0 0 watchdog timer disabled disabled enabled voltage detection circuit disabled or enabled disabled or enabled disabled or enabled i/o port pin status hiz hiz hiz special function register refer to the sfr map. refer to the sfr map. refer to the sfr map. note:the voltage detection circuits are disabled by an external reset input or power-on reset only. tmp89ch42 2. cpu core 2.4 reset control circuit page 40 rb000
2.4.4 reset signal generating factors reset signals are generated by each factor as follows: 2.4.4.1 power-on reset the power-on reset is an internal reset that occurs when power is turned on. during power-up, a power-on reset signal is generated while the supply voltage is below the power-on reset release voltage. when the supply voltage rises above the power-on reset release voltage, the power-on reset signal is released. during power-down, a power-on reset signal is generated when the supply voltage falls below the power- on reset detection voltage. refer to "power-on reset circuit". 2.4.4.2 external reset input ( reset pin input) this is an external reset that is generated by the reset pin input. port p10 is also used as the reset pin, and it is configured as the reset pin at power-up. ? during power-up - when the supply voltage rises rapidly when the power supply rise time (t vdd ) is shorter than 5 [ms] with enough margin, the reset can be released by a power-on reset or an external reset ( reset pin input). the power-on reset logic and external reset ( reset pin input) logic are ored. this means that the tmp89ch42 is reset when either or both of these reset sources are asserted. therefore, the reset time is determined by the reset source with a longer reset period. if the reset pin level changes from low to high before the supply voltage rises above the power-on-reset release voltage (v proff ) (or if the reset pin level is high from the be- ginning), the reset time depends on the power-on reset. if the reset pin level changes from low to high after the supply voltage rises above v proff , the reset time depends on the external reset. in the former case, a warm-up period begins when the power-on reset signal is released. in the latter case, a warm-up period begins when the reset pin level becomes high. upon completion of the warm-up period, the cpu and peripheral circuits start operating (figure 2-15). - when the supply voltage rises slowly when the power supply rise time (t vdd ) is longer than 5 [ms], the reset must be released by using the reset pin. in this case, hold the reset pin low until the supply voltage rises to the operating voltage range and oscillation is stabilized. when this state is achieved, wait at least 5 [s] and then pull the reset pin high. changing the reset pin level to high starts a warm-up period. upon completion of the warm-up period, the cpu and peripheral circuits start operating (figure 2-15). tmp89ch42 page 41 rb000
figure 2-15 external reset input (during power-up) tmp89ch42 2. cpu core 2.4 reset control circuit page 42 rb000 operating voltage range v proff t vdd reset pin warm-up period (t pwup ) when the supply voltage rises rapidly (when the reset time depends on external reset) cpu and peripheral circuits start operating cpu and peripheral circuits reset power-on reset operating voltage range v proff 5 s or more t vdd reset pin warm-up period (t pwup ) when the supply voltage rises slowly cpu and peripheral circuits start operating cpu and peripheral circuits reset power-on reset operating voltage range v proff t vdd reset pin warm-up period (t pwup ) when the supply voltage rises rapidly (when the reset time depends on power-on reset) cpu and peripheral circuits start operating cpu and peripheral circuits reset power-on reset
? when the supply voltage is within the operating voltage range when the supply voltage is within the operating voltage range and stable oscillation is achieved, holding the reset pin low for 5 [ s] or longer generates a reset. then, changing the reset pin level to high starts a warm-up period. upon completion of the warm-up period, the cpu and peripheral circuits start operating (figure 2-16). figure 2-16 external reset input (when the power supply is stable) 2.4.4.3 voltage detection reset the voltage detection reset is an internal factor reset that occurs when it is detected that the supply voltage has reached a predetermined detection voltage. refer to "voltage detection circuit". 2.4.4.4 watchdog timer reset the watchdog timer reset is an internal factor reset that occurs when an overflow of the watchdog timer is detected. refer to "watchdog timer". 2.4.4.5 system clock reset the system clock reset is an internal factor reset that occurs when it is detected that the oscillation enable register is set to a combination that puts the cpu into deadlock. refer to "clock control circuit". 2.4.4.6 trimming data reset the trimming data reset is an internal factor reset that occurs when the trimming data latched in the internal circuit is broken down during operation due to noise or other factors. the trimming data is a data bit provided for adjustment of the ladder resistor that generates the comparison voltage for the power-on reset and the voltage detection circuits. this bit is loaded from the non-volatile exclusive use memory during the warm-up time that follows reset release (tpwup) and latched into the internal circuit. if the trimming data loaded from the non-volatile exclusive use memory during the warm-up operation that follows reset release is abnormal, irstsr is set to "1". tmp89ch42 page 43 rb000 operating voltage range reset pin warm-up period (t pwup ) cpu and peripheral circuits start operating cpu and peripheral circuits reset 5 s or more
when irstsr is read as "1" in the initialize routine immediately after reset release, the trim- ming data need to be reloaded by generating an internal factor reset, such as a system clock reset, and activating the warm-up operation again. if irstsr is still set to "1" after repeated reading, the detection voltage of the voltage detection circuit and power-on reset circuit does not satisfy the characteristic specified in the electric characteristics. design the system so that the system will not be damaged in such a case. 2.4.4.7 internal factor reset detection status register by reading the internal factor reset detection status register irstsr after the release of an internal factor reset, except the power-on reset, the factor which causes a reset can be detected. the internal factor reset detection status register is initialized by an external reset input or power-on re- set. set irstsr to "1" and write 0x71 to syscr4. this enables irstsr and the internal factor reset detection status register is clear to "0". irstsr is cleared to "0" automatically after initializing the internal factor reset detection status register. note 1: care must be taken in system designing since the irstsr may not fulfill its functions due to disturbing noise and other effects. note 2: after irstsr is modified, syscr4 should be written 0x71 (enable code for irstsr in normal mode when fcgck is fc/4 (cgcr=00). otherwise, irstsr may be enabled at unexpected timing. 2.4.4.8 how to use the external reset input pin as a port to use the external reset input pin as a port, keep the external reset input pin at the "h" level until the power is turned on and the warm-up operation that follows reset release is finished. after the warm-up operation that follows reset release is finished, set p1pu0 to "1" and p1cr0 to "0", and connect a pull-up resistor for a port. then set syscr3 to "1" and write 0xb2 to syscr4. this disables the external reset function and makes the external reset input pin usable as a normal port. to use the pin as an external reset pin when it is used as a port, set p1pu0 to "1" and p1cr0 to "0" and connect the pull-up resistor to put the pin to the input mode. then clear syscr3 to "0" and write 0xb2 to syscr4. this enables the external reset function and makes the pin usable as the external reset input pin. note 1: if you switch the external reset input pin to a port or switch the pin used as a port to the external reset input pin, do it when the pin is stabilized at the "h" level. switching the pin function when the "l" level is input may cause a reset. note 2: if the external reset input is used as a port, the statement which clears syscr3 to "0" is not written in a program. by the abnormal execution of program, the external reset input set as a port may be changed as the external reset input at unexpected timing. note 3: after syscr3 is modified, syscr4 should be written 0xb2 (enable code for syscr3) in normal1 mode when fcgck is fc/4 (cgcr=00). otherwise, syscr3 may be enabled at unexpected timing. tmp89ch42 2. cpu core 2.4 reset control circuit page 44 rb000
2.5 revision history rev description ra002 "table 2-3 operation modes and conditions" added ad converter condition. "(2) release the stop mode" added new example program and note to level-sensitive release mode. ra003 "table 2-3 operation modes and conditions" revised character code error. "table 2-3 operation modes and conditions" added ad converter condition. "(2) release the stop mode" added new example program. ra004 "2.3.6 operation mode control" revised register name from vdcr2 to vdcr2. " internal factor reset detection status register" revised note. "2.4.4.2 external reset input (reset pin input)" revised description. rb000 revised p03 (xtin) and p04 (xtout) to p02 (xtin) and p03 (xtout). deleted srss function. tmp89ch42 page 45 rb000
tmp89ch42 2. cpu core 2.5 revision history page 46 rb000
3. interrupt control circuit the tmp89ch42 has a total of 25 interrupt sources excluding reset. interrupts can be nested with priorities. three of the internal interrupt sources are non-maskable while the rest are maskable. interrupt sources are provided with interrupt latches (il), which hold interrupt requests, and have independent vector addresses. when a request for an interrupt is generated, its interrupt latch is set to "1", which requests the cpu to accept the interrupt. acceptance of interrupts is enabled or disabled by software using the interrupt master enable flag (imf) and individual enable flag (ef) for each interrupt source. if multiple maskable interrupts are generated simul- taneously, the interrupts are accepted in order of descending priority. the priorities are determined by the interrupt priority change control register (ilprs1-ilprs6) as levels and determined by the hardware as the basic priorities. however, there are no prioritized interrupt sources among non-maskable interrupts. interrupt sources enable condition interrupt latch vector address (mcu mode) basic priori- ty rvctr=0 enabled rvctr=1 enabled internal/ex- ternal (reset) non-maskable - 0xfffe - 1 internal intswi non-maskable - 0xfffc 0x01fc 2 internal intundef non-maskable - 0xfffc 0x01fc 2 internal intwdt non-maskable ill 0xfff8 0x01f8 2 internal intwuc imf and eirl = 1 ill 0xfff6 0x01f6 5 internal inttbt imf and eirl = 1 ill 0xfff4 0x01f4 6 internal intrxd0 / intsio0 imf and eirl = 1 ill 0xfff2 0x01f2 7 internal inttxd0 imf and eirl = 1 ill 0xfff0 0x01f0 8 external int5 imf and eirh = 1 ilh 0xffee 0x01ee 9 internal intvltd imf and eirh = 1 ilh 0xffec 0x01ec 10 internal intadc imf and eirh = 1 ilh 0xffea 0x01ea 11 internal intrtc imf and eirh = 1 ilh 0xffe8 0x01e8 12 internal inttc00 imf and eirh = 1 ilh 0xffe6 0x01e6 13 internal inttc01 imf and eirh = 1 ilh 0xffe4 0x01e4 14 internal inttca0 imf and eirh = 1 ilh 0xffe2 0x01e2 15 internal intsbi0/intsio0 imf and eirh = 1 ilh 0xffe0 0x01e0 16 external int0 imf and eire = 1 ile 0xffde 0x01de 17 external int1 imf and eire = 1 ile 0xffdc 0x01dc 18 external int2 imf and eire = 1 ile 0xffda 0x01da 19 external int3 imf and eire = 1 ile 0xffd8 0x01d8 20 external int4 imf and eire = 1 ile 0xffd6 0x01d6 21 internal inttca1 imf and eire = 1 ile 0xffd4 0x01d4 22 internal intrxd1 imf and eire = 1 ile 0xffd2 0x01d2 23 internal inttxd1 imf and eire = 1 ile 0xffd0 0x01d0 24 internal inttc02 imf and eird = 1 ild 0xffce 0x01ce 25 internal inttc03 imf and eird = 1 ild 0xffcc 0x01cc 26 - - - - - - - - - - - - - - note 1: to use the watchdog timer interrupt (intwdt), clear wdctr to "0" (it is set for the "reset request" after reset is released). for details, see "watchdog timer". note 2: vector address areas can be changed by the syscr3 setting. to assign vector address areas to ram, set syscr3 to "1" and syscr3 to "1". tmp89ch42 page 47 ra003
3.1 configuration figure 3-1 interrupt control circuit tmp89ch42 3. interrupt control circuit 3.1 configuration page 48 ra003 s a3 2 1 0 4 b q il 4 il 4 il 5 il 6 il 7 il 8 il 9 il 10 il 11 il 12 il 13 il 14 il 15 il 16 il 17 il 18 il 19 il 20 il 21 r s q imf r internal factor reset en intswi intundef intwdt interrupt source 4 interrupt source 5 interrupt source 6 interrupt source 7 interrupt source 8 interrupt source 9 interrupt source 10 interrupt source 11 interrupt source 12 interrupt source 13 interrupt source 14 interrupt source 15 interrupt source 16 interrupt source 17 interrupt source 18 interrupt source 19 interrupt source 20 decoder vector address generation priority encoder di instruction interrupt accept idle1/2,sleep1/2 mode clear request interrupt request imf (interrupt master enable flag) internal factor reset instruction to write ?0? to imf non-maskable interrupts maskable interrupts maskable interrupt priority change circuit ilprs1 ilprs2 ilprs3 ilprs4 s q il 3 r 5 4 3 1 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 data bus address bus il 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 [retn] instruction [ret1]1 instruction (only when the imf is set to ?1? before interrupt acceptance) (only when the imf is set to ?1? before interrupt acceptance) [ei] instruction instruction to write ?1? to imf il3 vector read signal il4 clear signal il4 vector read signal reading ilprs6 25 ef 25 to ef 4 il 25 interrupt source25 il 25 to il 4
3.2 interrupt latches (il25 to il3) an interrupt latch is provided for each interrupt source, except for a software interrupt and an undefined instruction execution interrupt. when an interrupt request is generated, the latch is set to "1", and the cpu is requested to accept the interrupt if its acceptance is enabled. the interrupt latch is cleared to "0" immediately after the interrupt is accepted. all interrupt latches are initialized to "0" during reset. the interrupt latches are located at addresses 0x0fe0, 0x0fe1, 0x0fe2, 0x0fe3 in sfr area. each latch can be cleared to "0" individually by an instruction. however, il2 and il3 interrupt latches cannot be cleared by instructions. do not use any read-modify-write instruction, such as a bit manipulation or operation instruction, because it may clear interrupt requests generated while the instruction is executed. interrupt latches cannot be set to "1" by using an instruction. writing "1" to an interrupt latch is equivalent to denying clearing of the interrupt latch, and not setting the interrupt latch. since interrupt latches can be read by instructions, the status of interrupt requests can be monitored by software. note: in the main program, before manipulating an interrupt latch (il), be sure to clear the master enable flag (imf) to "0" (disable interrupt by di instruction). then set the imf to "1" as required after operating the il (enable interrupt by ei instruction). in the interrupt service routine, the imf becomes "0" automatically and need not be cleared to "0" normally. however, if using multiple interrupt in the interrupt service routine, manipulate the il before setting the imf to "1". example 1: clears interrupt latches di ; imf 0 ld (ill), 0y00111111 ; il7 to il6 0 ld (ilh), 0y11101000 ; il12, il10 to il8 0 ei ; imf 1 example 2: reads interrupt latches ld wa, (ill) ; w ilh, a ill example 3: tests interrupt latches test (ill). 7 ; if il7=1 then jump jr f, sset ; tmp89ch42 page 49 ra003
3.3 interrupt enable register (eir) the interrupt enable register (eir) enables and disables the acceptance of interrupts, except for the non-maskable interrupts (software interrupt, undefined instruction interrupt and watchdog interrupt). non-maskable interrupts are accepted regardless of the contents of the eir. the eir consists of the interrupt master enable flag (imf) and the individual interrupt enable flags (ef). these registers are located at addresses 0x003a, 0x003b, 0x003c, 0x003d in the sfr area, and they can be read and written by instructions (including read-modify-write instructions such as bit manipulation or operation instructions). 3.3.1 interrupt master enable flag (imf) the interrupt master enable flag (imf) enables and disables the acceptance of all maskable interrupts. clearing the imf to "0" disables the acceptance of all maskable interrupts. setting the imf to "1" enables the acceptance of the interrupts that are specified by the individual interrupt enable flags. when an interrupt is accepted, the imf is stacked and then cleared to "0", which temporarily disables the subsequent maskable interrupts. after the interrupt service routine is executed, the stacked data, which was the status before interrupt acceptance, reloaded on the imf by return interrupt instruction [reti]/[retn]. the imf is located on bit 0 in eirl (address: 0x03a in sfr), and can be read and written by instructions. the imf is normally set and cleared by [ei] and [di] instructions respectively. during reset, the imf is initialized to "0". 3.3.2 individual interrupt enable flags (ef25 to ef4) each of these flags enables and disables the acceptance of its maskable interrupt. setting the corresponding bit of an individual interrupt enable flag to "1" enables acceptance of its interrupt, and setting the bit to "0" disables acceptance. during reset, all the individual interrupt enable flags are initialized to "0" and no maskable interrupts are accepted until the flags are set to "1". note: in the main program, before manipulating the interrupt enable flag (ef), be sure to clear the master enable flag (imf) to "0" (disable interrupt by di instruction). then set the imf to "1" as required after operating the ef (enable interrupt by ei instruction). in the interrupt service routine, the imf becomes "0" automatically and need not be cleared to "0" nor- mally. however, if using multiple interrupt in the interrupt service routine, manipulate the ef before setting the imf to "1". example: enables interrupts individually and sets imf di ; imf 0 ldw : (eirl), 0y1110100010100000 ; ; ef15 to ef13, ef11, ef7, ef5 1 note: imf should not be set. : ei ; imf 1 tmp89ch42 3. interrupt control circuit 3.3 interrupt enable register (eir) page 50 ra003
interrupt latch (ill) ill 7 6 5 4 3 2 1 0 (0x0fe0) bit symbol il7 il6 il5 il4 il3 - - - read/write r/w r/w r/w r/w r r r r after reset 0 0 0 0 0 0 0 0 function inttxd0 intrxd0 / intsio0 inttbt intwuc intwdt interrupt latch (ilh) ilh 7 6 5 4 3 2 1 0 (0x0fe1) bit symbol il15 il14 il13 il12 il11 il10 il9 il8 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function intsbi0/in- tsio0 inttca0 inttc01 inttc00 intrtc intadc intvltd int5 interrupt latch (ile) ile 7 6 5 4 3 2 1 0 (0x0fe2) bit symbol il23 il22 il21 il20 il19 il18 il17 il16 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function inttxd1 intrxd1 inttca1 int4 int3 int2 int1 int0 interrupt latch (ild) ild 7 6 5 4 3 2 1 0 (0x0fe3) bit symbol - - - - - - il25 il24 read/write r r r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 function inttc03 inttc02 il25 to il4 interrupt latch read write 0: no interrupt request clears the interrupt request (notes 2 and 3) 1: interrupt request does not clear the interrupt re- quest (interrupt is not set by writing "1".) il3 0: 1: no interrupt request interrupt request - note 1: il3 is a read-only register. writing the register does not affect interrupt latch. note 2: in the main program, before manipulating an interrupt latch (il), be sure to clear the interrupt master enable flag (imf) to "0" (disable interrupt by di instruction). then set the imf to "1" as required after operating the il (enable interrupt by ei instruction). in the interrupt service routine, the imf becomes "0" automatically and need not be cleared to "0" normally. however, if using multiple interrupt in the interrupt service routine, manipulate the il before setting the imf to "1". note 3: do not clear il with read-modify-write instructions such as bit operations. note 4: when a read instruction is executed on ill, bits 0 to 2 are read as "0". other unused bits are read as "0". tmp89ch42 page 51 ra003
interrupt enable register (eirl) eirl 7 6 5 4 3 2 1 0 (0x003a) bit symbol ef7 ef6 ef5 ef4 - - - imf read/write r/w r/w r/w r/w r r r r/w after reset 0 0 0 0 0 0 0 0 function inttxd0 intrxd0 / intsio0 inttbt intwuc interrupt master ena- ble flag interrupt enable register (eirh) eirh 7 6 5 4 3 2 1 0 (0x003b) bit symbol ef15 ef14 ef13 ef12 ef11 ef10 ef9 ef8 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function intsbi0/in- tsio0 inttca0 inttc01 inttc00 intrtc intadc intvltd int5 interrupt enable register (eire) eire 7 6 5 4 3 2 1 0 (0x003c) bit symbol ef23 ef22 ef21 ef20 ef19 ef18 ef17 ef16 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function inttxd1 intrxd1 inttca1 int4 int3 int2 int1 int0 interrupt enable register (eird) eird 7 6 5 4 3 2 1 0 (0x003d) bit symbol - - - - - - ef25 ef24 read/write r r r r r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function inttc03 inttc02 ef25 to ef4 individual interrupt enable flag (specified for each bit) 0: 1: disables the acceptance of each maskable interrupt. enables the acceptance of each maskable interrupt. imf interrupt master enable flag 0: 1: disables the acceptance of all maskable interrupts. enables the acceptance of all maskable interrupts. note 1: do not set the imf and the interrupt enable flag (ef15 to ef4) to "1" at the same time. note 2: in the main program, before manipulating the interrupt enable flag (ef), be sure to clear the master enable flag (imf) to "0" (disable interrupt by di instruction). then set the imf to "1" as required after operating the ef (enable interrupt by ei instruction) in the interrupt service routine, the imf becomes "0" automatically and need not be cleared to "0" normally. however, if using multiple interrupt in the interrupt service routine, manipulate the ef before setting the imf to "1". note 3: when a read instruction is executed on eirl, bits 3 to 1 are read as "0". other unused bits are read as "0". tmp89ch42 3. interrupt control circuit 3.3 interrupt enable register (eir) page 52 ra003
3.4 maskable interrupt priority change function the priority of maskable interrupts (il4 to il25) can be changed to four levels, levels 0 to 3, regardless of the basic priorities 5 to 26. interrupt priorities can be changed by the interrupt priority change control register (ilprs1 to ilprs6 ). to raise the interrupt priority, set the level to a larger number. to lower the interrupt priority, set the level to a smaller number. when different maskable interrupts are generated simultaneously at the same level, the interrupt with higher basic priority is processed preferentially. for example, when the ilprs1 register is set to 0xc0 and interrupts il4 and il7 are generated at the same time, il7 is preferentially processed (provided that ef4 and ef7 have been enabled). after reset is released, all maskable interrupts are set to priority level 0 (the lowest priority). note: in the main program, before manipulating the interrupt priority change control register (ilprs1 to 6), be sure to clear the master enable flag (imf) to "0" (disable interrupt by di instruction). set the imf to "1" as required after operating ilprs1 to 6 (enable interrupt by ei instruction). in the interrupt service routine, the imf becomes "0" automatically and need not be cleared to "0" normally. however, if using multiple interrupt in the interrupt service routine, manipulate ilprs1 to 6 before setting the imf to "1". interrupt priority change control register 1 ilprs1 7 6 5 4 3 2 1 0 (0x0ff0) bit symbol il07p il06p il05p il04p read/write r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 il07p sets the interrupt priority of il7. 00: level 0 (lower priority) il06p sets the interrupt priority of il6. 01: level 1 il05p sets the interrupt priority of il5. 10: level 2 il04p sets the interrupt priority of il4. 11: level 3 (higher priority) interrupt priority change control register 2 ilprs2 7 6 5 4 3 2 1 0 (0x0ff1) bit symbol il11p il10p il09p il08p read/write r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 il11p sets the interrupt priority of il11. 00: level 0 (lower priority) il10p sets the interrupt priority of il10. 01: level 1 il09p sets the interrupt priority of il9. 10: level 2 il08p sets the interrupt priority of il8. 11: level 3 (higher priority) interrupt priority change control register 3 ilprs3 7 6 5 4 3 2 1 0 (0x0ff2) bit symbol il15p il14p il13p il12p read/write r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 il15p sets the interrupt priority of il15. 00: level 0 (lower priority) il14p sets the interrupt priority of il14. 01: level 1 il13p sets the interrupt priority of il13. 10: level 2 il12p sets the interrupt priority of il12. 11: level 3 (higher priority) tmp89ch42 page 53 ra003
interrupt priority change control register 4 ilprs4 7 6 5 4 3 2 1 0 (0x0ff3) bit symbol il19p il18p il17p il16p read/write r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 il19p sets the interrupt priority of il19. 00: level 0 (lower priority) il18p sets the interrupt priority of il18. 01: level 1 il17p sets the interrupt priority of il17. 10: level 2 il16p sets the interrupt priority of il16. 11: level 3 (higher priority) interrupt priority change control register 5 ilprs5 7 6 5 4 3 2 1 0 (0x0ff4) bit symbol il23p il22p il21p il20p read/write r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 il23p sets the interrupt priority of il23. 00: level 0 (lower priority) il22p sets the interrupt priority of il22. 01: level 1 il21p sets the interrupt priority of il21. 10: level 2 il20p sets the interrupt priority of il20. 11: level 3 (higher priority) interrupt priority change control register 6 ilprs6 7 6 5 4 3 2 1 0 (0x0ff5) bit symbol - - il25p il24p read/write r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 - - 00: level 0 (lower priority) - - 01: level 1 il25p sets the interrupt priority of il25. 10: level 2 il24p sets the interrupt priority of il24. 11: level 3 (higher priority) tmp89ch42 3. interrupt control circuit 3.4 maskable interrupt priority change function page 54 ra003
3.5 interrupt sequence an interrupt request, which raised interrupt latch, is held, until interrupt is accepted or interrupt latch is cleared to 0 by resetting or an instruction. interrupt acceptance sequence requires 8-machine cycles after the completion of the current instruction. the interrupt service task terminates upon execution of an interrupt return instruction [reti] (for maskable interrupts) or [retn] (for non-maskable interrupts). 3.5.1 initial setting using an interrupt requires specifying an sp (stack pointer) for it in advance. the sp is a 16-bit register pointing at the start address of a stack. the sp is post-decremented when a subroutine call or a push instruction is executed or when an interrupt request is accepted. it is pre-incremented when a return or pop instruction is executed. therefore, the stack becomes deeper toward lower stack location addresses. be sure to reserve a stack area having an appropriate size based on the sp setting. the sp is initialized to 00ffh after a reset. if you need to change the sp, do so right after a reset or when the interrupt master enable flag (imf) is 0. example :sp setting ld sp, 023fh ; sp = 023fh ld sp, sp+04h ; sp = sp + 04h add sp, 0010h ; sp = sp + 0010h 3.5.2 interrupt acceptance processing interrupt acceptance processing is packaged as follows. 1. the interrupt master enable flag (imf) is cleared to 0 in order to disable the acceptance of any following interrupt. 2. the interrupt latch (il) for the interrupt source accepted is cleared to 0. 3. the contents of the program counter (pc) and the program status word, including the interrupt master enable flag (imf), are saved (pushed) on the stack in sequence of psw + imf, pch, pcl. meanwhile, the stack pointer (sp) is decremented by 3. 4. the entry address (interrupt vector) of the corresponding interrupt service program, loaded on the vector table, is transferred to the program counter. 5. the instruction stored at the entry address of the interrupt service program is executed. note: when the contents of psw are saved on the stack, the contents of register bank and imf are also saved. example: correspondence between vector table address for inttbt and the entry address of the interrupt service program figure 3-2 vector table address and entry address tmp89ch42 page 55 ra003 0x03 0xfff4 0xfff5 vector table address 0xd2 0x0f 0xd203 0xd204 vector table address 0x06
a maskable interrupt is not accepted until the imf is set to 1 even if the maskable interrupt is requested in the interrupt service routine. in order to utilize nested interrupt service, the imf must be set to 1 in the interrupt service program. in this case, acceptable interrupt sources are selectively enabled by the individual interrupt enable flags. to avoid overloaded nesting, clear the individual interrupt enable flag whose interrupt is currently serviced, before setting imf to 1. as for non-maskable interrupt, keep interrupt service shorter compared with length between interrupt requests. 3.5.3 saving/restoring general-purpose registers during interrupt acceptance processing, the program counter (pc) and the program status word (psw, includes imf) are automatically saved on the stack, but the general purpose registers are not. these registers must be saved by software if necessary. when multiple interrupt services are nested, it is also necessary to avoid using the same data memory area for saving registers. the following methods are used to save/restore the general-purpose reg- isters. 3.5.3.1 using push and pop instructions to save only a specific register, push and pop instructions are available. example :using push and pop instructions pintxx push wa ; save wa register interrupt processing pop wa ; restore wa register reti ; return figure 3-3 saving/restoring general-purpose registers tmp89ch42 3. interrupt control circuit 3.5 interrupt sequence page 56 ra003 at acceptance of an interrupt psw sp pc l pc h address (example) b-4 b-3 b-2 b-1 b psw sp pc l pc h at execution of push instruction at execution of pop instruction sp at execution of an reti instruction psw w a sp pc l pc h
3.5.3.2 using data transfer instructions to save only a specific register without nested interrupts, data transfer instructions are available. example :save/store register using data transfer instructions pintxx: ld (gsava), a ; save a register interrupt processing ld a, (gsava) ; restore a register reti ; return figure 3-4 saving/restoring general-purpose registers under interrupt processing 3.5.3.3 using a register bank to save/restore general-purpose registers in non-multiple interrupt handling, the register bank function can be used to save/restore the general- purpose registers at a time. the register bank function saves (switches) the general-purpose registers by executing a register bank manipulation instruction (such as ld rbs,1) at the beginning of an interrupt service task. it is unnecessary to re-execute the register bank manipulation instruction at the end of the interrupt service task because executing the reti instruction makes a return automatically to the register bank that was being used by the main task according to the content of the psw. note: two register banks (bank0 and bank1) are available. each bank consists of 8-bit general-purpose registers (w, a, b, c, d, e, h, and l) and 16-bit general-purpose registers (ix and iy). example :saving/restoring registers, using an instruction for transfer with data memory (with the main task using the register bank bank0) pintxx: ld rbs, 1 ; switches to the register bank bank1 interrupt processing reti ; return (makes a return automatically to bank0 that was being used by the main task when the psw is restored) tmp89ch42 page 57 ra003 main task interrupt acceptance interrupt service task saving registers restoring registers interrupt return
figure 3-5 saving/restoring general-purpose registers under interrupt processing 3.5.4 interrupt return interrupt return instructions [reti]/[retn] perform as follows. [reti]/[retn] interrupt return 1. program counter (pc) and program status word (register bank) are re- stored from tha stack. 2. stack pointer (sp) is incremented by 3. tmp89ch42 3. interrupt control circuit 3.5 interrupt sequence page 58 ra003 main task interrupt service task interrupt acceptance interrupt return switching occurs to the register bank bank1. a return is made automatically to the register bank bank0. ld (rbs),1 the register bank bank0 is in use.
3.6 software interrupt (intsw) executing the swi instruction generates a software interrupt and immediately starts interrupt processing (intsw is the top-priority interrupt). use the swi instruction only for address error detection or for debugging described below. 3.6.1 address error detection 0xff is read if for some cause such as noise the cpu attempts to fetch an instruction from a non-existent memory address. code 0xff is an swi instruction, so a software interrupt is generated and an address error is detected. the address error detection range can be further expanded by writing 0xff to unused areas in the program memory. 3.6.2 debugging debugging efficiency can be increased by placing the swi instruction at the software break point setting address. 3.7 undefined instruction interrupt (intundef) when the cpu tries to fetch and execute an instruction that is not defined, intundef is generated and starts the interrupt processing. intundef is accepted even if another non-maskable interrupt is in process. the current process is discontinued and the intundef interrupt process starts soon after it is requested. note: the undefined instruction interrupt (intundef) forces the cpu to jump into the interrupt vector address, as software interrupt (swi) does. tmp89ch42 page 59 ra003
3.8 revision history rev description ra003 revised from wdtcr1 to wdctr added chapter "3.5 interrupt sequence" "figure 3-3 saving/restoring general-purpose registers" revised sp position tmp89ch42 3. interrupt control circuit 3.8 revision history page 60 ra003
4. external interrupt control circuit external interrupts detects the change of the input signal and generates an interrupt request. noise can be removed by the built-in digital noise canceller. 4.1 configuration the external interrupt control circuit consists of a noise canceller, an edge detection circuit, a level detection circuit and an interrupt signal generation circuit. externally input signals are input to the rising edge or falling edge or level detection circuit for each external interrupt, after noise is removed by the noise canceller. figure 4-1 external interrupts 0/5 figure 4-2 external interrupts 1/2/3 figure 4-3 external interrupt 4 4.2 control external interrupts are controlled by the following registers: tmp89ch42 page 61 ra000 noise canceller 3 4 2 1 fcgck int4 pin int4lvl int4es int4 interrupt request abcd s z rising edge detection circuit interrupt request signal generation circuit level detection circuit falling edge detection circuit eintcr4 fs noise canceller 3 4 2 1 fcgck fs/4 inti pin intilvl inties inti interrupt request i=1 to 3 abcd s z rising edge detection circuit interrupt request signal generation circuit falling edge detection circuit eintcri noise canceller intj pin fs/4 fcgck intj interrupt request j=0,5 falling edge detection circuit interrupt request signal generation circuit
low power consumption register 3 poffcr3 7 6 5 4 3 2 1 0 (0x0f77) bit symbol - - int5en int4en int3en int2en int1en int0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 int5en int5 control 0 1 disable enable int4en int4 control 0 1 disable enable int3en int3 control 0 1 disable enable int2en int2 control 0 1 disable enable int1en int1 control 0 1 disable enable int0en int0 control 0 1 disable enable note 1: clearing intxen(x=0 to 5) to "0" stops the clock supply to the external interrupts. this invalidates the data written in the control register for each external interrupt. when using the external interrupts, set intxen to "1" and then write data into the control register for each external interrupt. note 2: interrupt request signals may be generated when intxen is changed. before changing intxen, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the operation mode is changed from normal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. note 3: bits 7 and 6 of poffset3 are read as "0". external interrupt control register 1 eintcr1 (0x0fd8) 7 6 5 4 3 2 1 0 bit symbol - - - int1lvl int1es int1nc read/write r r r r r/w r/w after reset 0 0 0 0 0 0 ini1lvl noise canceller pass signal level when the interrupt request signal is generated for external interrupt 1 0 : 1 : initial state or signal level "l" signal level "h" int1es selects the interrupt request gener- ating condition for external interrupt 1 00 : an interrupt request is generated at the rising edge of the noise canceller pass signal 01 : an interrupt request is generated at the falling edge of the noise canceller pass signal 10 : an interrupt request is generated at both edges of the noise canceller pass signal 11 : reserved int1nc sets the noise canceller sampling in- terval for external interrupt 1 normal1/2, idle1/2 slow1/2, sleep1 00 : 01 : 10 : 11 : fcgck [hz] fcgck / 2 2 [hz] fcgck / 2 3 [hz] fcgck / 2 4 [hz] 00 : 01 : 10 : 11 : fs/4 [hz] fs/4 [hz] fs/4 [hz] fs/4 [hz] note 1: fcgck: gear clock [hz], fs: low-frequency clock [hz] note 2: interrupt requests may be generated during transition of the operation mode. before changing the operation mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the operation mode is changed from normal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. tmp89ch42 4. external interrupt control circuit 4.2 control page 62 ra000
note 3: interrupt requests may be generated when eintcr1 is changed. before doing such operation, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the operation mode is changed from nor- mal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/ fspl [s] after the operation mode is changed and clear the interrupt latch. note 4: bits 7 to 5 of eintcr1 are read as "0". external interrupt control register 2 eintcr1 (0x0fd9) 7 6 5 4 3 2 1 0 bit symbol - - - int2lvl int2es int2nc read/write r r r r r/w r/w after reset 0 0 0 0 0 0 ini2lvl noise canceller pass signal level when the interrupt request signal is generated for external interrupt 2 0 : 1 : initial state or signal level "l" signal level "h" int2es selects the interrupt request gener- ating condition for external interrupt 2 00 : an interrupt request is generated at the rising edge of the noise canceller pass signal 01 : an interrupt request is generated at the falling edge of the noise canceller pass signal 10 : an interrupt request is generated at both edges of the noise canceller pass signal 11 : reserved int2nc sets the noise canceller sampling in- terval for external interrupt 2 normal1/2, idle1/2 slow1/2, sleep1 00 : 01 : 10 : 11 : fcgck [hz] fcgck / 2 2 [hz] fcgck / 2 3 [hz] fcgck / 2 4 [hz] 00 : 01 : 10 : 11 : fs/4 [hz] fs/4 [hz] fs/4 [hz] fs/4 [hz] note 1: fcgck: gear clock [hz], fs: low-frequency clock [hz] note 2: interrupt requests may be generated during transition of the operation mode. before changing the operation mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the operation mode is changed from normal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. note 3: interrupt requests may be generated when eintcr2 is changed. before doing such operation, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the operation mode is changed from nor- mal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/ fspl [s] after the operation mode is changed and clear the interrupt latch. note 4: bits 7 to 5 of eintcr2 are read as "0". tmp89ch42 page 63 ra000
external interrupt control register 3 eintcr3 (0x0fda) 7 6 5 4 3 2 1 0 bit symbol - - - int3lvl int3es int3nc read/write r r r r r/w r/w after reset 0 0 0 0 0 0 ini3lvl noise canceller pass signal level when the interrupt request signal is generated for external interrupt 3 0 : 1 : initial state or signal level "l" signal level "h" int3es selects the interrupt request gener- ating condition for external interrupt 3 00 : an interrupt request is generated at the rising edge of the noise canceller pass signal 01 : an interrupt request is generated at the falling edge of the noise canceller pass signal 10 : an interrupt request is generated at both edges of the noise canceller pass signal 11 : reserved int3nc sets the noise canceller sampling in- terval for external interrupt 3 normal1/2, idle1/2 slow1/2, sleep1 00 : 01 : 10 : 11 : fcgck [hz] fcgck / 2 2 [hz] fcgck / 2 3 [hz] fcgck / 2 4 [hz] 00 : 01 : 10 : 11 : fs/4 [hz] fs/4 [hz] fs/4 [hz] fs/4 [hz] note 1: fcgck: gear clock [hz], fs: low-frequency clock [hz] note 2: interrupt requests may be generated during transition of the operation mode. before changing the operation mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the operation mode is changed from normal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. note 3: interrupt requests may be generated when eintcr3 is changed. before doing such operation, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the operation mode is changed from nor- mal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/ fspl [s] after the operation mode is changed and clear the interrupt latch. note 4: bits 7 to 5 of eintcr3 are read as "0". tmp89ch42 4. external interrupt control circuit 4.2 control page 64 ra000
external interrupt control register 4 eintcr4 (0x0fdb) 7 6 5 4 3 2 1 0 bit symbol - - - int4lvl int4es int4nc read/write r r r r r/w r/w after reset 0 0 0 0 0 0 ini4lvl noise canceller pass signal level when the interrupt request signal is generated for external interrupt 4 0 : 1 : initial state or signal level "l" signal level "h" int4es selects the interrupt request gener- ating condition for external interrupt 4 00 : an interrupt request is generated at the rising edge of the noise canceller pass signal 01 : an interrupt request is generated at the falling edge of the noise canceller pass signal 10 : an interrupt request is generated at both edges of the noise canceller pass signal 11 : an interrupt request is generated at "h" of the noise canceller pass signal int4nc sets the noise canceller sampling in- terval for external interrupt 4 normal1/2, idle1/2 slow1/2, sleep1 00 : 01 : 10 : 11 : fcgck [hz] fcgck / 2 2 [hz] fcgck / 2 3 [hz] fcgck / 2 4 [hz] 00 : 01 : 10 : 11 : fs/4 [hz] fs/4 [hz] fs/4 [hz] fs/4 [hz] note 1: fcgck: gear clock [hz], fs: low-frequency clock [hz] note 2: interrupt requests may be generated during transition of the operation mode. before changing the operation mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the operation mode is changed from normal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. note 3: interrupt requests may be generated when eintcr4 is changed. before doing such operation, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the operation mode is changed from nor- mal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/ fspl [s] after the operation mode is changed and clear the interrupt latch. note 4: the contents of eintcrx are updated each time an interrupt request signal is generated. note 5: bits 7 to 5 of eintcr4 are read as "0". 4.3 function the condition for generating interrupt request signals and the noise cancel time can be set for external interrupts 1 to 4. the condition for generating interrupt request signals and the noise cancel time are fixed for external interrupts 0 and 5. tmp89ch42 page 65 ra000
table 4-1 external interrupts source pin enable conditions interrupt request sig- nal generated at external interrupt pin input signal width and noise removal normal1/2, idle1/2 slow1/2, sleep1 int0 int0 imf and ef16 = 1 falling edge less than 1/fcgck: noise more than 1/fcgck and less than 2/fcgck: indeterminate more than 2/fcgck: signal less than 4/fs: noise more than 4/fs and less than 8/fs: inde- terminate more than 8/fs: signal int1 int1 imf and ef17 = 1 falling edge rising edge both edges less than 2/fspl: noise more than 2/fspl and less than 3/fspl+1/ fcgck: indeterminate more than 3/fspl+1/fcgck: signal less than 4/fs: noise more than 4/fs and less than 8/fs: inde- terminate more than 8/fs: signal int2 int2 imf and ef18 = 1 falling edge rising edge both edges less than 2/fspl: noise more than 2/fspl and less than 3/fspl+1/ fcgck: indeterminate more than 3/fspl+1/fcgck: signal less than 4/fs: noise more than 4/fs and less than 8/fs: inde- terminate more than 8/fs: signal int3 int3 imf and ef19 = 1 falling edge rising edge both edges less than 2/fspl: noise more than 2/fspl and less than 3/fspl+1/ fcgck: indeterminate more than 3/fspl+1/fcgck: signal less than 4/fs: noise more than 4/fs and less than 8/fs: inde- terminate more than 8/fs: signal int4 int4 imf and ef20 = 1 falling edge rising edge both edges "h" level less than 2/fspl: noise more than 2/fspl and less than 3/fspl+1/ fcgck: indeterminate more than 3/fspl+1/fcgck: signal less than 4/fs: noise more than 4/fs and less than 8/fs: inde- terminate more than 8/fs: signal int5 int5 imf and ef8 = 1 falling edge less than 1/fcgck: noise more than 1/fcgck and less than 2/fcgck: indeterminate more than 2/fcgck: signal less than 4/fs: noise more than 4/fs and less than 8/fs: inde- terminate more than 8/fs: signal note 1: fcgck, gear clock [hz]; fs, low frequency clock [hz]; fspl, sampling interval [hz] 4.3.1 low power consumption function external interrupts have a function that saves power by using the low power consumption register (poffcr3) when they are not used. setting poffcr 3 to "0" stops (disables) the basic clock for external interrupts and helps save power. note that this makes external interrupts unavailable. setting poffcr3 to "1" supplies (ena- bles) the basic clock for external interrupts and makes external interrupts available. after reset, poffcr 3 is initialized to "0" and external interrupts become unavailable. when using the external interrupt function for the first time, be sure to set poffcr 3 to "1" in the initial setting of software (before operating the external interrupt control registers). note: interrupt request signals may be generated when intxen is changed. before changing intxen, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the oper- ation mode is changed from normal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. 4.3.2 external interrupt 0 external interrupt 0 detects the falling edge of the int0 pin and generates interrupt request signals. in normal1/2 or idle1/2 mode, pulses of less than 1/fcgck are removed as noise and pulses of 2/fcgck or more are recognized as signals. in slow/sleep mode, pulses of less than 4/fs are removed as noise and pulses of 8/fs or more are recognized as signals. tmp89ch42 4. external interrupt control circuit 4.3 function page 66 ra000
4.3.3 external interrupts 1/2/3 external interrupts 1/2/3 detect the falling edge, the rising edge or both edges of the int1, int2 and int3 pins and generate interrupt request signals. 4.3.3.1 interrupt request signal generating condition detection function select interrupt request signal generating conditions at eintcrx for external interrupts 1/2/3. table 4-2 selection of interrupt request generation edge eintcrx detected at 00 rising edge 01 falling edge 10 both edges 11 reserved note:x=1 to 3 4.3.3.2 a noise canceller pass signal monitoring function when interrupt request signals are generated the level of a signal that has passed through the noise canceller when an interrupt request is generated can be read by using eintcrx. when both edges are selected as detection edges, the edge where an interrupt is generated can be detected by reading eintcrx. note:the contents of eintcrx are updated each time an interrupt request signal is generated. figure 4-4 interrupt request generation and eintcrx 4.3.3.3 noise cancel time selection function in normal1/2 or idle1/2 mode, a signal that has been sampled by fcgck is sampled at the sampling interval selected at eintcrx. if the same level is detected three consecutive times, the signal is recognized as a signal. if not, the signal is removed as noise. tmp89ch42 page 67 ra000 signal that has passed through the noise canceller inti pin interrupt request signal (detected at the falling edge) interrupt request signal (detected at the rising edge) interrupt request signal (detected at both edges) int lvl int lvl int lvl
table 4-3 noise canceller sampling lock eintcrx sampling interval 00 fcgck 01 fcgck/2 2 10 fcgck/2 3 11 fcgck/2 4 figure 4-5 noise cancel operation in slow1/2 or sleep1 mode, a signal is sampled by the low frequency clock divided by 4. if the same level is detected twice consecutively, the signal is recognized as a signal. in idle0, sleep0 or stop mode, the noise canceller sampling operation is stopped and an external interrupts are unavailable. when operation returns to normal1/2, idle1/2, slow1/2 or sleep1 mode, sampling operation restarts. note 1: if noise is input consecutively during sampling of external interrupt pins, the noise cancel function does not work properly. set eintcrx according to the cycle of externally input noise. note 2: if an external interrupt pin is used as an output port, the input signal to the port is fixed to "l" when the mode is switched to the output mode, and thus an interrupt request occurs. to use the pin as an output port, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. note 3: interrupt requests may be generated during transition of the operation mode. before changing the op- eration mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the operation mode is changed from normal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. 4.3.4 external interrupt 4 external interrupt 4 detects the falling edge, the rising edge, both edges or "h" level of the int4 pin and generates interrupt request signals. 4.3.4.1 interrupt request signal generating condition detection function select an interrupt request signal generating condition at eintcr4 for external interrupt 4. table 4-4 selection of interrupt request generation edge eintcr4 detected at 00 rising edge 01 falling edge 10 both edges 11 "h" level interrupt tmp89ch42 4. external interrupt control circuit 4.3 function page 68 ra000 inti pin signal after noise removal i=1 to 3 noise signal
4.3.4.2 a noise canceller pass signal monitoring function when interrupt request signals are generated the level of a signal that has passed through the noise canceller when an interrupt request is generated can be read by using eintcr4. when both edges are selected as detection edges, the edge where an interrupt is generated can be detected by reading eintcr4. figure 4-6 interrupt request generation and eintcr4 4.3.4.3 noise cancel time selection function in normal1/2 or idle1/2 mode, a signal that has been sampled by fcgck is sampled at the sampling interval selected at eintcrx. if the same level is detected three consecutive times, the signal is recognized as a signal. if not, the signal is removed as noise. table 4-5 noise canceller sampling lock eintcr4 sampling interval 00 fcgck 01 fcgck/2 2 10 fcgck/2 3 11 fcgck/2 4 tmp89ch42 page 69 ra000 int4 pin interrupt request signal (detected at the falling edge) interrupt request signal (detected at the rising edge) interrupt request signal (detected at both edges) int4lvl int4lvl int4lvl int4lvl interrupt request signal (level detection) signal that has passed through the noise canceller
figure 4-7 noise cancel operation in slow1/2 or sleep1 mode, a signal is sampled by the low frequency clock divided by 4. if the same level is detected twice consecutively, the signal is recognized as a signal. in idle0, sleep0 or stop mode, the noise canceller sampling operation is stopped and an external interrupts are unavailable. when operation returns to normal1/2, idle1/2, slow1/2 or sleep1 mode, sampling operation restarts. note 1: when noise is input consecutively during sampling external interrupt pins, the noise cancel function does not work properly. set eintcrx according to the cycle of externally input noise. note 2: when an external interrupt pin is used as an output port, the input signal to the port is fixed to "l" when the mode is switched to the output mode, and thus an interrupt request occurs. to use the pin as an output port, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. note 3: interrupt requests may be generated during transition of the operation mode. before changing the op- eration mode, clear the corresponding interrupt enable register to "0" to disable the generation of interrupt. when the operation mode is changed from normal1/2 or idle1/2 to slow1/2 or sleep1, wait 12/fs [s] after the operation mode is changed and clear the interrupt latch. and when the operation mode is changed from slow1/2 or sleep1 to normal1/2 or idle1/2, wait 2/fcgck+3/fspl [s] after the operation mode is changed and clear the interrupt latch. 4.3.5 external interrupt 5 external interrupt 5 detects the falling edge of the int5 pin and generates interrupt request signals. in normal1/2 or idle1/2 mode, pulses of less than 1/fcgck are removed as noise and pulses of 2/fcgck or more are recognized as signals. in slow/sleep mode, pulses of less than 4/fs are removed as noise and pulses of 8/fs or more are recognized as signals. tmp89ch42 4. external interrupt control circuit 4.3 function page 70 ra000 int4 pin signal after noise removal noise signal
5. watchdog timer (wdt) the watchdog timer is a fail-safe system to detect rapidly the cpu malfunctions such as endless loops due to spurious noises or the deadlock conditions, and return the cpu to a system recovery routine. the watchdog timer signals used for detecting malfunctions can be programmed as watchdog interrupt request signals or watchdog timer reset signals. note: care must be taken in system designing since the watchdog timer may not fulfill its functions due to disturbing noise and other effects. 5.1 configuration figure 5-1 watchdog timer configuration tmp89ch42 page 71 ra000 source clock watchdog timer interrupt requestl cpu/peripheral circuits reset fcgck/2 10 or fs/2 3 fcgck/2 12 or fs/2 5 fcgck/2 14 or fs/2 7 fcgck/2 16 or fs/2 9 watchdog timer reset signal 2 8 wdctr wdcdr wdcnt wdst overflow clear 2 3 4 6 7 8 5 control code decoder disable control circuit disable code (0xb1) clear code (0x4e) n e t d w w t d w t t d w t u o t d w t s t d w 1 t s t n i w 2 t s t n i w clear time control circuit 8-bit up counter interrupt request/reset signal control circuit r o t c e l e s
5.2 control the watchdog timer is controlled by the watchdog timer control register (wdctr), the watchdog timer control code register (wdcdr), the watchdog timer counter monitor (wdcnt) and the watchdog timer status (wdst). the watchdog timer is enabled automatically just after the warm-up operation that follows reset is finished. watchdog timer control register wdctr (0x0fd4) 7 6 5 4 3 2 1 0 bit symbol - - wdten wdtw wdtt wdtout read/write r r r/w r/w r/w r/w after reset 1 0 1 0 0 1 1 0 wdten enables/disables the watchdog tim- er operation. 0 : 1 : disable enable wdtw sets the clear time of the 8-bit up counter. 00 : the 8-bit up counter is cleared by writing the clear code at any point within the overflow time of the 8-bit up counter. 01 : a watchdog timer interrupt request is generated by writing the clear code at a point within the first quarter of the overflow time of the 8-bit up counter. the 8-bit up counter is cleared by writing the clear code after the first quarter of the overflow time has elapsed. 10 : a watchdog timer interrupt request is generated by writing the clear code at a point within the first half of the overflow time of the 8-bit up counter. the 8-bit up counter is cleared by writing the clear code after the first half of the overflow time has elapsed. 11 : a watchdog timer interrupt request is generated by writing the clear code at a point within the first three quarters of the overflow time of the 8-bit up counter. the 8-bit up counter is cleared by writing the clear code after the first three quarters of the overflow time have elapsed. wdtt sets the overflow time of the 8-bit up counter. normal mode slow mode dv9ck=0 dv9ck=1 00 : 2 18 /fcgck 2 11 /fs 2 11 /fs 01: 2 20/ fcgck 2 13 /fs 2 13 /fs 10: 2 22 /fcgck 2 15 /fs 2 15 /fs 11: 2 24 /fcgck 2 17 /fs 2 17 /fs wdtout selects an overflow detection signal of the 8-bit up counter. 0 : 1 : watchdog timer interrupt request signal watchdog timer reset request signal note 1: fcgck, gear clock [hz]; fs, low frequency clock [hz] note 2: wdctr, wdctr and wdctr cannot be changed when wdctr is "1". if wdctr is "1", clear wdctr to "0" and write the disable code (0xb1) into wdcdr to disable the watchdog timer operation. note that wdctr, wdctr and wdctr can be changed at the same time as setting wdctr to "1". note 3: bit 7 and bit 6 of wdctr are read as "1" and "0" respectively. watchdog timer control code register wdcdr (0x0fd5) 7 6 5 4 3 2 1 0 bit symbol wdtcr2 read/write w after reset 0 0 0 0 0 0 0 0 wdtcr2 writes watchdog timer control co- des. 0x4e : clears the watchdog timer. (clear code) 0xb1 : disables the watchdog timer operation and clears the 8-bit up counter when wdctr is "0". (disable code) others : invalid tmp89ch42 5. watchdog timer (wdt) 5.2 control page 72 ra000
note: wdcdr is a write-only register and must not be accessed by using a read-modify-write instruction, such as a bit operation. 8-bit up counter monitor wdcnt (0x0fd6) 7 6 5 4 3 2 1 0 bit symbol wdcnt read/write r after reset 0 0 0 0 0 0 0 0 wdcnt monitors the count value of the 8-bit up counter the count value of the 8-bit up counter is read. watchdog timer status wdst (0x0fd7) 7 6 5 4 3 2 1 0 bit symbol - - - - - wintst2 wintst1 wdtst read/write r r r r r r r r after reset 0 1 0 1 1 0 0 1 wintst2 watchdog timer interrupt request signal factor status 2 0 : no watchdog timer interrupt request signal has occurred. 1 : a watchdog timer interrupt request signal has occurred due to the overflow of the 8-bit up counter. wintst1 watchdog timer interrupt request signal factor status 1 0 : no watchdog timer interrupt request signal has occurred. 1 : a watchdog timer interrupt request signal has occurred due to releasing of the 8-bit up counter outside the clear time. wdtst watchdog timer operating state sta- tus 0 : 1 : operation disabled operation enabled note 1: wdst and wdst are cleared to "0" by reading wdst. note 2: values after reset are read from bits 7 to 3 of wdst. tmp89ch42 page 73 ra000
5.3 functions the watchdog timer can detect the cpu malfunctions and deadlock by detecting the overflow of the 8-bit up counter and detecting releasing of the 8-bit up counter outside the clear time. the watchdog timer stoppage and other abnormalities can be detected by reading the count value of the 8-bit up counter at random times and comparing the value to the last read value. 5.3.1 setting of enabling/disabling the watchdog timer operation setting wdctr to "1" enables the watchdog timer operation, and the 8-bit up counter starts counting the source clock. wdctr is initialized to "1" after the warm-up operation that follows reset is released. this means that the watchdog timer is enabled. to disable the watchdog timer operation, clear wdctr to "0" and write 0xb1 into wdcdr. disabling the watchdog timer operation clears the 8-bit up counter to "0". note: if the overflow of the 8-bit up counter occurs at the same time as 0xb1 (disable code) is written into wdcdr with wdctr set at "1", the watchdog timer operation is disabled preferentially and the overflow detection is not executed. to re-enable the watchdog timer operation, set wdctr to "1". there is no need to write a control code into wdcdr. figure 5-2 wdctr set timing and overflow time note: the 8-bit up counter source clock operates out of synchronization with wdctr. therefore, the first overflow time of the 8-bit up counter after wdctr is set to "1" may get shorter by a maximum of 1 source clock. the 8-bit up counter must be cleared within the period of the overflow time minus 1 source clock cycle. 5.3.2 setting the clear time of the 8-bit up counter wdctr sets the clear time of the 8-bit up counter. when wdctr is "00", the clear time is equal to the overflow time of the 8-bit up counter, and the 8-bit up counter can be cleared at any time. when wdctr is not "00", the clear time is fixed to only a certain period within the overflow time of the 8-bit up counter. if the operation for releasing the 8-bit up counter is attempted outside the clear time, a watchdog timer interrupt request signal occurs. at this time, the watchdog timer is not cleared but continues counting. if the 8-bit up counter is not cleared within the clear time, a watchdog timer reset request signal or a watchdog timer interrupt request signal occurs due to the overflow, depending on the wdctr setting. tmp89ch42 5. watchdog timer (wdt) 5.3 functions page 74 ra000 wdctr 0x00 0x01 0xff wdctr 0x00 watchdog timer source clock 8-bit up counter value interrupt request signal 1 clock (max.) overflow time overflow time
figure 5-3 wdctr and the 8-bit up counter clear time 5.3.3 setting the overflow time of the 8-bit up counter wdctr sets the overflow time of the 8-bit up counter. when the 8-bit up counter overflows, a watchdog timer reset request signal or a watchdog timer interrupt request signal occurs, depending on the wdctr setting. if the watchdog timer interrupt request signal is selected as the malfunction detection signal, the watchdog counter continues counting, even after the overflow has occurred. the watchdog timer temporarily stops counting up in the stop mode (including warm-up) or in the idle/ sleep mode, and restarts counting up after the stop/idle/sleep mode is released. to prevent the 8-bit up counter from overflowing immediately after the stop/idle/sleep mode is released, it is recommended to clear the 8-bit up counter before the operation mode is changed. table 5-1 watchdog timer overflow time (fcgck=10.0 mhz; fs=32.768 khz) wdtt watchdog timer overflow time [s] normal mode slow mode dv9ck = 0 dv9ck = 1 00 26.21 m 62.50 m 62.50 m 01 104.86 m 250.00 m 250.00 m 10 419.43 m 1.000 1.000 11 1.678 4.000 4.000 note: the 8-bit up counter source clock operates out of synchronization with wdctr. therefore, the first overflow time of the 8-bit up counter after wdctr is set to "1" may get shorter by a maximum of 1 source clock. the 8-bit up counter must be cleared within a period of the overflow time minus 1 source clock cycle. 5.3.4 setting an overflow detection signal of the 8-bit up counter wdctr selects a signal to be generated when the overflow of the 8-bit up counter is detected. 1. when the watchdog timer interrupt request signal is selected (when wdctr is "0") releasing wdctr to "0" causes a watchdog timer interrupt request signal to occur when the 8-bit up counter overflows. a watchdog timer interrupt is a non-maskable interrupt, and its request is always accepted, regardless of the interrupt master enable flag (imf) setting. note: when a watchdog timer interrupt is generated while another interrupt, including a watchdog timer interrupt, is already accepted, the new watchdog timer interrupt is processed immediately and the preceding interrupt is put on hold. therefore, if watchdog timer interrupts are generated continuously without execution of the retn in- struction, too many levels of nesting may cause a malfunction of the microcontroller. tmp89ch42 page 75 ra000 when wdctr is ?00? 8-bit up counter value when wdctr is ?01? when wdctr is ?10? when wdctr is ?11? 0x40 0x7f 0x80 0xbf 0xc0 0xff 0x00 0xff 0x00 0x01 0x3f clear time clear time outside the clear time clear time outside the clear time clear time outside the clear time
2. when the watchdog timer reset request signal is selected (when wdctr is "1") setting wdctr to "1" causes a watchdog timer reset request signal to occur when the 8-bit up counter overflows. this watchdog timer reset request signal resets the tmp89ch42 and starts the warm-up operation. 5.3.5 writing the watchdog timer control codes the watchdog timer control codes are written into wdcdr. by writing 0x4e (clear code) into wdcdr, the 8-bit up counter is cleared to "0" and continues counting the source clock. when wdctr is "0", writing 0xb1 (disable code) into wdcdr disables the watchdog timer operation. to prevent the 8-bit up counter from overflowing, clear the 8-bit up counter in a period shorter than the overflow time of the 8-bit up counter and within the clear time. by designing the program so that no overflow will occur, the program malfunctions and deadlock can be detected through interrupts generated by watchdog timer interrupt request signals. by applying a reset to the microcomputer using watchdog timer reset request signals, the cpu can be restored from malfunctions and deadlock. example: when wdctr is "0", set the watchdog timer detection time to 2 20 / fcgck [s], set the counter clear time to half of the overflow time, and allow a watchdog timer reset request signal to occur if a malfunction is detected. ld (wdctr), 0y00110011 ; wdtw10, wdtt01, wdtout1 clear the 8-bit up counter at a point after half of its overflow time and within a period of the overflow time minus 1 source clock cycle. ld (wdcdr), 0x4e ; clear the 8-bit up counter clear the 8-bit up counter at a point after half of its overflow time and within a period of the overflow time minus 1 source clock cycle. ld (wdcdr), 0x4e ; clear the 8-bit up counter note: if the overflow of the 8-bit up counter and writing of 0x4e (clear code) into wdcdr occur simultaneously, the 8-bit up counter is cleared preferentially and the overflow detection is not executed. 5.3.6 reading the 8-bit up counter the counter value of the 8-bit up counter can be read by reading wdcnt. the stoppage of the 8-bit up counter can be detected by reading wdcnt at random times and comparing the value to the last read value. 5.3.7 reading the watchdog timer status the watchdog timer status can be read at wdst. wdst is set to "1" when the watchdog timer operation is enabled, and it is cleared to "0" when the watchdog timer operation is disabled. wdst is set to "1" when a watchdog timer interrupt request signal occurs due to the overflow of the 8-bit up counter. tmp89ch42 5. watchdog timer (wdt) 5.3 functions page 76 ra000
wdst is set to "1" when a watchdog timer interrupt request signal occurs due to the operation for releasing the 8-bit up counter outside the clear time. you can know which factor has caused a watchdog timer interrupt request signal by reading wdst and wdst in the watchdog timer interrupt service routine. wdst and wdst are cleared to "0" when wdst is read. if wdst is read at the same time as the condition for turning wdst or wdst to "1" is satisfied, wdst or wdst is set to "1", rather than being cleared. figure 5-4 changes in the watchdog timer status tmp89ch42 page 77 ra000 8-bit up counter value when wdctr is ?10? writing of 4eh (clear code) wdst watchdog timer interrupt request signal interrupt request signal generated by clearing the 8-bit up counter outside the clear time interrupt request signal generated by the overflow of the 8-bit up counter 0x40 0x01 0x7f 0x80 0xbf 0xc0 0xff 0x00 0xff 0x00 0x01 0x3f clear time outside the clear time reading of wdst wdst
tmp89ch42 5. watchdog timer (wdt) 5.3 functions page 78 ra000
6. power-on reset circuit the power-on reset circuit generates a reset when the power is turned on. when the supply voltage is lower than the detection voltage of the power-on reset circuit, a power-on reset signal is generated. 6.1 configuration the power-on reset circuit consists of a reference voltage generation circuit and a comparator. the supply voltage divided by ladder resistor is compared with the voltage generated by the reference voltage generation circuit by the comparator. figure 6-1 power-on reset circuit 6.2 function when power supply voltage goes on, if the supply voltage is equal to or lower than the releasing voltage of the power-on reset circuit, a power-on reset signal is generated and if it is higher than the releasing voltage of the power- on reset circuit, a power-on reset signal is released. when power supply voltage goes down, if the supply voltage is equal to or lower than the detecting voltage of the power-on reset circuit, a power-on reset signal is generated. until the power-on reset signal is generated, a warm-up circuit and a cpu is reset. when the power-on reset signal is released, the warm-up circuit is activated. the reset of the cpu and peripheral circuits is released after the warm-up time that follows reset release has elapsed. increase the supply voltage into the operating range during the period from detection of the power-on reset release voltage until the end of the warm-up time that follows reset release. if the supply voltage has not reached the operating range by the end of the warm-up time that follows reset release, the tmp89ch42 cannot operate properly. tmp89ch42 page 79 ra000 vdd power-on reset signal comparator reference voltage generation circuit
note 1: the power-on reset circuit may operate improperly, depending on fluctuations in the supply voltage (vdd). refer to the electrical characteristics and take them into consideration when designing equipment. note 2: for the ac timing, refer to the electrical characteristics. figure 6-2 operation timing of power-on reset tmp89ch42 6. power-on reset circuit 6.2 function page 80 ra000 supply voltage (vdd) vproff operating voltage vpron vdd ppw pron warm-up counter start pwup proff power-on reset signal warm-up counter clock cpu/peripheral circuits reset signal
7. voltage detection circuit the voltage detection circuit detects any decrease in the supply voltage and generates intvltd interrupt request signals and voltage detection reset signals. note: the voltage detection circuit may operate improperly, depending on fluctuations in the supply voltage (vdd). refer to the electrical characteristics and take them into consideration when designing equipment. 7.1 configuration the voltage detection circuit consists of a reference voltage generation circuit, a detection voltage level selection circuit, a comparator and control registers. the supply voltage (vdd) is divided by the ladder resistor and input to the detection voltage selection circuit. the detection voltage selection circuit selects a voltage according to the specified detection voltage (vdxlvl) (x = 1 or 2) , and the comparator compares it with the reference voltage. when the comparator detects the selected voltage, a voltage detection reset signal or an intvltd interrupt request signal can be generated. whether to generate a voltage detection reset signal or an intvltd interrupt request signal can be programmed by software. in the former case, a voltage detection reset signal is generated when the supply voltage (vdd) becomes lower than the detection voltage (vd x lvl). in the latter case, an intvltd interrupt request signal is generated when the supply voltage (vdd) falls to the detection voltage level. note: since the comparators used for voltage detection do not have a hysteresis structure, intvltd interrupt request signals may be generated frequently if the supply voltage (vdd) is close to the detection voltage (vdxlvl). intvltd interrupt request signals may be generated not only when the supply voltage falls to the detection voltage but also when it rises to the detection voltage. figure 7-1 voltage detection circuit tmp89ch42 page 81 rb000 vdd reference voltage generation circuit ? + ? + vd1en vd1mod vd2en vd2mod vd2lvl vd1lvl vd1sf vd1f vd2sf vd2f vdcr2 detection voltage 1 level selection circuit detection voltage 2 level selection circuit vdcr1 voltage detection reset signal 1 voltage detection reset signal 2 intvltd interrupt request signal f/f f/f interrupt request signal generation circuit internal bus
7.2 control the voltage detection circuit is controlled by voltage detection control registers 1 and 2. voltage detection control register 1 vdcr1 (0x0fc6) 7 6 5 4 3 2 1 0 bit symbol vd2f vd2sf vd2lvl vd1f vd1sf vd1lvl read/write r/w read only r/w r/w read only r/w after reset 0 0 1 0 0 0 0 0 vd2f voltage detection 2 flag (retains the state when vdd 7.3 function two detection voltages (vdxlvl, x = 1 to 2) can be set in the voltage detection circuit. for each voltage, e nabling/ disabling the voltage detection and the operation to be executed when the supply voltage (vdd) falls to or below the detection voltage (vdxlvl) can be programmed. 7.3.1 enabling/disabling the voltage detection operation setting vdcr2 to "1" enables the voltage detection operation. setting it to "0" disables the oper- ation. vdcr2 is cleared to "0" immediately after a power-on reset or a reset by an external reset input is released. note: when the supply voltage (vdd) is lower than the detection voltage (vd x lvl), setting vdcr2 to "1" generates an intvltd interrupt request signal or a voltage detection reset signal at the time. 7.3.2 selecting the voltage detection operation mode when vdcr2 is set to "0", the voltage detection operation mode is set to generate intvltd interrupt request signals. when vdcr2 is set to "1", the operation mode is set to generate voltage detection reset signals. ? when the operation mode is set to generate intvltd interrupt signals (vdcr2="0") when vdcr2="1", an intvltd interrupt request signal is generated when the supply voltage (vdd) falls to the detection voltage (vdxlvl). figure 7-2 voltage detection interrupt request note1: since the comparators used for voltage detection do not have a hysteresis structure, intvltd interrupt request signals may be generated frequently when the supply voltage (vdd) is close to the detection voltage (vdxlvl). intvltd interrupt request signals may be generated not only when the supply voltage falls to the detection voltage but also when it rises to the detection voltage. note2: in debug using the rte870/c1 in-circuit emulator (ice mode) with the tmp89c900 mounted on it, no interrupt is generated when the supply voltage rises to the detection voltage. since the #!undefined!# may operate differently, take account of this difference when debugging programs. note3: if the supply voltage (vdd) falls to the detection voltage (vdxlvl) during idle0 or sleep0 mode, an intvltd interrupt request signal is generated after the tbt counts the specified period and idle0 or sleep mode is released. in the case of stop mode, an intlvtd interrupt request signal is generated after stop mode is released by the stop pin. ? when the operation mode is set to generate voltage detection reset signals (vdcr2="1") when vdcr2 = "1", a voltage detection reset signal is generated when the supply voltage (vdd) becomes lower than the detection voltage (vdxlvl). tmp89ch42 page 83 rb000 detection voltage level vdd level intvltd interruptrequest signal (note1) vdcr2 (note1,2)
vdcr1 and vdcr2 are initialized by a power-on reset or an external reset input only. a voltage detection reset signal is generated continuously as long as the supply voltage (vdd) is lower than the detection voltage (vdxlvl). figure 7-3 voltage detection reset signal 7.3.3 selecting the detection voltage level select a detection voltage at vdcr1. 7.3.4 voltage detection flag and voltage detection status flag the magnitude relation between the supply voltage (vdd) and the detection voltage (vd x lvl) can be checked by reading vdcr1 and vdcr1. if vdcr2 is set at "1", when the supply voltage (vdd) becomes lower than the detection voltage (vdxlvl), vdcr1 is set to "1" and is held in this state. vdcr1 is not cleared to "0" when the supply voltage (vdd) becomes equal to or higher than the detection voltage (vdxlvl). when vdcr2 is cleared to "0" after vdcr1 is set to "1", the previous state is still held. to clear vdcr1, "0" must be written to it. if vdcr2 is set at "1", when the supply voltage (vdd) becomes lower than the detection voltage (vdxlvl), vdcr1 is set to "1". when the supply voltage (vdd) becomes equal to or higher than the detection voltage (vdxlvl), vdcr1 is cleared to "0". unlike vdcr1, vdcr1 does not hold the set state. note 1: when the supply voltage (vdd) becomes lower than the detection voltage (vd x lvl) in the stop, idle0 or sleep0 mode, the voltage detection flag and the voltage detection status flag are changed after the oper- ation mode is returned to normal or slow mode. note 2: depending on the voltage detection timing, the voltage detection status flag (vd x sf) may be changed earlier than the voltage detection flag (vdxf) by a maximum of 2/fcgck[s]. tmp89ch42 7. voltage detection circuit 7.3 function page 84 rb000 detection voltage level vdd level voltage detection reset signal vdcr2
figure 7-4 changes in the voltage detection flag and the voltage detection status flag tmp89ch42 page 85 rb000 detection voltage level vdd level vdcr2 vdcr1 vdcr1 write "0" to vdcr1 the flag is not set because vdcr2 is "0"
7.4 register settings 7.4.1 setting procedure when the operation mode is set to generate intvltd interrupt request signals when the operation mode is set to generate intvltd interrupt request signal, make the following setting: 1. clear the voltage detection circuit interrupt enable flag to "0". 2. set the detection voltage at vdcr1(x=1 to 2). 3. clear vdcr2 to "0" to set the operation mode to generate intvltd interrupt request signals. 4. set vdcr2 to "1" to enable the voltage detection operation. 5. wait for 5 [s] or more until the voltage detection circuit becomes stable. 6. make sure that vdcr1 is "0". 7. clear the voltage detection circuit interrupt latch to "0" and set the interrupt enable flag to "1" to enable interrupts. note: when the supply voltage (vdd) is close to the detection voltage (vdxlvl), voltage detection request signals may be generated frequently. if this may pose any problem, execute appropriate wait processing depending on fluctuations in the system power supply and clear the interrupt latch before returning from the intvltd interrupt service routine. to disable the voltage detection circuit while it is enabled with the intvltd interrupt request, make the following setting: 1. clear the voltage detection circuit interrupt enable flag to "0". 2. clear vdcr2 to "0" to disable the voltage detection operation. note: if the voltage detection circuit is disabled without clearing interrupt enable flag, unexpected interrupt request may occur. 7.4.2 setting procedure when the operation mode is set to generate voltage detection reset signals when the operation mode is set to generate voltage detection reset signals, make the following setting: 1. clear the voltage detection circuit interrupt enable flag to "0". 2. set the detection voltage at vdcr1(x=1 to 2). 3. clear vdcr2 to "0" to set the operation mode to generate intvltd interrupt request signals. 4. set vdcr2 to "1" to enable the voltage detection operation. 5. wait for 5 [s] or more until the voltage detection circuit becomes stable. 6. make sure that vdcr1 is "0". 7. clear vdcr1 to "0". 8. set vdcr2 to "1" to set the operation mode to generate voltage detection reset signals. note 1: vdcr1 and vdcr2 are initialized by a power-on reset or an external reset input only. if the supply voltage (vdd) becomes lower than the detection voltage (vd x lvl) in the period from release of the voltage detection reset until clearing of vdcr2 to "0", a voltage detection reset signal is generated immediately. note 2: the voltage detection reset signals are generated continuously as long as the supply voltage (vdd) is lower than the detection voltage (vdxlvl). to disable the voltage detection circuit while it is enabled with the voltage detection reset, make the following setting: 1. clear the voltage detection circuit interrupt enable flag to "0". tmp89ch42 7. voltage detection circuit 7.4 register settings page 86 rb000
2. clear vdcr2 to "0" to set the operation mode to generate intvltd interrupt request signals. 3. clear vdcr2 to "0" to disable the voltage detection operation. note: if the voltage detection circuit is disabled without clearing interrupt enable flag, unexpected interrupt request may occur. tmp89ch42 page 87 rb000
7.5 revision history rev description ra001 " voltage detection control register 1" revised vd1lvl and vd2lvl. ra002 revised from vdcr2 to vdcr1 ra003 "7.4.1 setting procedure when the operation mode is set to generate intvltd interrupt request signals" added description to disable the voltage detection circuit. "7.4.2 setting procedure when the operation mode is set to generate voltage detection reset signals" added description to disable the voltage detection circuit. added step 7. " voltage detection control register 2" added note 3. "7.3.5 selecting the stop mode release signal" added note 4. ra004 revised "voltage detection interrupt" to "intvltd interrupt". revised initial value of vdcr1 "00" to "10". rb000 deleted vdcr2 function. added note of intvltd interrupt. "7.3.2 selecting the voltage detection operation mode" revised description. tmp89ch42 7. voltage detection circuit 7.5 revision history page 88 rb000
8. i/o ports the tmp89ch42 has 8 parallel input/output ports (40 pins) as follows: table 8-1 list of i/o ports port name pin name number of pins input/output secondary functions port p0 p03 to p00 (note) 4 (note) input/output also used as the high-frequency oscillator connection pin and the low- frequency oscillator connection pin port p1 p13 to p10 4 input/output also used as the external reset input, the external interrupt input and the stop mode release signal input port p2 p27 to p20 8 input/output also used as the uart input/output, the serial interface input/output and the serial bus interface input/output port p4 p47 to p40 8 input/output also used as the analog input and the key-on wakeup input port p7 p77 to p70 8 input/output also used as the timer counter input/output, the divider output and the external interrupt input port p8 p81 to p80 2 input/output also used as the timer counter input/output port p9 p91 to p90 2 input/output also used as the uart input/output port pb pb7 to pb4 4 input/output also used as the uart input/output and the serial interface input/out- put note: p00 and p01 pins can not be used for the i/o port, because they should be connected with the high frequency osc input. tmp89ch42 page 89 ra007
each output port contains a latch, which holds the output data. no input port has a latch, so the external input data should be externally held until the input data is read from outside or reading should be performed several times before processing. figure 8-1 shows input/output timing examples. external data is read from an i/o port in the read cycle during execution of the read instruction. this timing cannot be recognized from outside, so that transient input such as chattering must be processed by the program. data is output to an i/o port in the next cycle of the write cycle during execution of the write instruction. figure 8-1 input/output timing (example) note:the positions of the read and write cycles may vary, depending on the instruction. tmp89ch42 8. i/o ports page 90 ra007 instruction execution cycle system clock internal read signal data input example: ld a, (x) fetch cycle fetch cycle read cycle instruction execution cycle internal write signal data output example: ld (x), a fetch cycle fetch cycle (a) input timing write cycle (b) output timing system clock
8.1 i/o port control registers the following control registers are used for i/o ports. (the port number is indicated in place of x.) registers that can be set vary depending on the port. for details, refer to the description of each port. ? pxdr register this is the register for setting output data. when a port is set to the "output mode", the value specified at pxdr is output from the port. ? pxprd register this is the register for reading input data. when a port is set to the "input mode", the current port input status can be read by reading pxprd. ? pxcr register this register switches a port between input and output. a port can be switched between the "input mode" and the "output mode". ? pxfc register this register enables the secondary function output of each port. the secondary function output of each port can be enabled or disabled. ? pxoutcr register this register switches the port output between the c-mos output and the open drain output. ? pxpu register this register determines whether or not the built-in pull-up resistor is connected when a port is used in the input mode or as the open drain output. tmp89ch42 page 91 ra007
8.2 list of i/o port settings for the setting methods for individual i/o ports, refer to the following table. table 8-2 list of i/o port settings port name pin name function register set value pxcr pxoutcr pxfc other required settings port p0 p03 to p00 port input 0 without register 0 port output 1 0 p03 xtout * without register p02 xtin * 1 p01 xout * without register p00 xin * 1 port p1 p13 to p11 port input 0 without register without register port output 1 p10 port input 0 note 1 p10 port output 1 note 1 p13 int1 input 0 p12 int0 input 0 p11 int5 input 0 p11 stop input 0 p10 reset input * note 1 port p2 p27 to p20 port input 0 * * port output 1 ** 0 p25 sclk0 input 0 * * sersel="01" sclk0 output 1 ** 1 sersel="01" p24 scl0 input/output 1 without register 1 sersel="*0" si input 0 * sersel="01" p23 sda0 input/output 1 without register 1 sersel="*0" so output 1 1 sersel="01" p22 sclk0 input 0 * * sersel="10" sersel="0" sclk0 output 1 ** 1 sersel="10" sersel="0" p21 rxd0 input 0 * * sersel="0*" sersel="0" uatcng="0" txd0 output 1 ** 1 sersel="0*" sersel="0" uatcng="1" si0 input 0 * * sersel="10" sersel="0" p20 txd0 output 1 ** 1 sersel="0*" sersel="0" uatcng="0" rxd0 input 0 * * sersel="0*" sersel="0" uatcng="1" so0 output 1 ** 1 sersel="10" sersel="0" tmp89ch42 8. i/o ports 8.2 list of i/o port settings page 92 ra007
table 8-2 list of i/o port settings port name pin name function register set value pxcr pxoutcr pxfc other required settings port p4 p47 to p40 port input 0 without register 0 port output 1 0 ain7 to ain0 0 1 kwi7 to kwi4 * * kwucr1 kwi3 to kwi0 * * kwucr0 port p7 p77 to p70 port input 0 without register * port output 1 0 p77 int4 input 0 without register p76 int3 input 0 without register p75 int2 input 0 without register p74 dvo output 1 1 p73 tca1 input 0 * ppga1 output 1 1 p72 tca0 input 0 * sersel="00" ppga0 output 1 1 p71 tc01 input 0 * ppg01 / pwm01 output 1 1 p70 tc00 input 0 * ppg00 / pwm00 output 1 1 port p8 p81 to p80 port input 0 without register * port output 1 0 p81 tc03 input 0 * ppg03 / pwm03 output 1 1 p80 tc02 input 0 * ppg02 / pwm02 output 1 1 port p9 p92 to p90 port input 0 * * port output 1 ** 0 p91 rxd1 input 0 * 0 uatcng="0" txd1 output 1 ** 1 uatcng="1" p90 txd1 output 1 ** 1 uatcng="0" rxd1 input 0 * 0 uatcng="1" port pb pb7 to pb4 port input 0 * * port output 1 ** 0 pb6 sclk0 input 0 * * sersel="10" sersel="1" sclk0 output 1 ** 1 sersel="10" sersel="1" pb5 rxd0 input 0 * * sersel="0*" sersel="1" uatcng="0" txd0 output 1 ** 1 sersel="0*" sersel="1" uatcng="1" si0 input 0 * * sersel="10" sersel="1" tmp89ch42 page 93 ra007
table 8-2 list of i/o port settings port name pin name function register set value pxcr pxoutcr pxfc other required settings pb4 txd0 output 1 ** 1 sersel="0*" sersel="1" uatcng="0" rxd0 input 0 * * sersel="0*" sersel="1" uatcng="1" so0 output 1 ** 1 sersel="10" sersel="1" note 1: after the power is turned on, pin p10 serves as an external reset input. to use pin p10 as a port, refer to "how to use the external reset input pin as a port". note 2: about sersel, please refer to "8.4 serial interface selecting function". note 3: the symbol and numeric characters in the table have the following meanings: symbol and nu- meric characters meaning 0 set "0". 1 set "1". * dont care (operation is the same whether "1" or "0" is selected.) ** the sink open drain output or the c-mos output can be selec- ted. without register there is no register that corresponds to the bit. tmp89ch42 8. i/o ports 8.2 list of i/o port settings page 94 ra007
8.3 i/o port registers 8.3.1 port p0 (p03 to p00) port p0 is a 4-bit input/output port that can be set to input or output for each bit individually, and it is also used as the high-frequency oscillation connection pin and the low-frequency oscillation connection pin. port p0 contains a programmable pull-up resistor on the vdd side. this pull-up resistor can be used when the port is used in the input mode. table 8-3 port p0 - - - - p03 p02 p01 p00 secondary function - - - - xtout xtin xout xin figure 8-2 port p0 (p00, p01) tmp89ch42 page 95 ra007 output latch (for each bit) p0dr0 write p00 (xin) r note1 : r = 100 ? (typ.) note2 : rf = 1.2m ? (typ.) note3 : ro = 0.5k ? (typ.) note4 : r in3 = 50k ? (typ.) p0prd0 read function control (for each bit) input/output control (for each bit) p0fc0 write p0cr0 write vdd vdd pull-up control (for each bit) p0pu0 write syscr2 p0dr1 write p01 (xout) r r in3 r in3 rf ro p0prd1 read system clock reset (internal factor reset) p0cr1 write programmable pull-up resistor programmable pull-up resistor vdd vdd p0pu1 write syscr1 syscr1 reset signal (reset 2) pull-up control (for each bit) input/output control (for each bit) output latch (for each bit) internal data bus
figure 8-3 port p0 (p02, p03) tmp89ch42 8. i/o ports 8.3 i/o port registers page 96 ra007 internal data bus output latch (for each bit) p0dr2 write p02 (xtin) r rf p0prd2 read function control (for each bit) input/output control (for each bit) p0fc2 write p0cr2 write vdd vdd pull-up control (for each bit) p0pu2 write syscr2 output latch (for each bit) p0dr3 write p03 (xtout) r r in3 r in3 p0prd3 read input/output control (for each bit) p0cr3 write programmable pull-up resistor programmable pull-up resistor vdd vdd pull-up control (for each bit) p0pu3 write syscr1 syscr1 reset signal note1 : r = 100 ? (typ.) note2 : rf = 6m ? (typ.) note3 : ro = 220k ? (typ.) note4 : r in3 = 50k ? (typ.) ro
port p0 output latch p0dr (0x0000) 7 6 5 4 3 2 1 0 bit symbol - - - - p03 p02 p01 p00 read/write r r r r r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: outputs l level when the output mode is selected. 1: outputs h level when the output mode is selected. port p0 input/output control p0cr (0x0f1a) 7 6 5 4 3 2 1 0 bit symbol - - - - p0cr3 p0cr2 p0cr1 p0cr0 read/write r r r r r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: input mode (port input) 1: output mode (port output) note:p0cr1 and p0cr0 must be clear to "0". port p0 function control p0fc (0x0f34) 7 6 5 4 3 2 1 0 bit symbol - - - - - p0fc2 - p0fc0 read/write r r r r r r/w r r/w after reset 0 0 0 0 0 0 0 1 function 0: port func- tion port func- tion 1: xtin (i) xin (i) note 1: when syscr2 is "1", setting p0fc0 to "0" generates a system clock (internal factor) reset. normally, ports p00 or p01 are not used as ports, so p0fc0 must be set to "1". note 2: symbol "i" means secondary function input port p0 built-in pull-up resistor control p0pu (0x0f27) 7 6 5 4 3 2 1 0 bit symbol - - - - p0pu2 p0pu2 p0pu1 p0pu0 read/write r r r r r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: the built-in pull-up resistor is not connected. 1: the built-in pull-up resistor is connected. (the resistor is connected in the input mode only. under any other con- ditions, setting to "1" does not make the resistor connec- ted.) tmp89ch42 page 97 ra007
port p0 input data p0prd (0x000d) 7 6 5 4 3 2 1 0 bit symbol - - - - p0prd3 p0prd2 p0prd1 p0prd0 read/write r r r r r r r r after reset 0 0 0 0 * * * * function if the port is in the input mode, the contents of the port are read. if not, "0" is read. table 8-4 p0prd read value (p00 to p01) set condition p0prdi read value p0fc0 p0cri * 1 "0" 1 * "0" 0 0 contents of port note 1: * : dont care note 2: i = 0, 1 table 8-5 p0prd read value (p02 to p03) set condition p0prdj read value p0fc2 p0crj * 1 "0" 1 * "0" 0 0 contents of port note 1: * : dont care note 2: j = 2, 3 tmp89ch42 8. i/o ports 8.3 i/o port registers page 98 ra007
8.3.2 port p1 (p13 to p10) port p1 is a 4-bit input/output port that can be set to input or output for each bit individually, and is also used as the external interrupt input, the stop mode release signal input and the external reset input. port p1 contains a programmable pull-up resistor on the vdd side. this pull-up resistor can be used when the port is used in the input mode. after reset, pin p10 serves as the external reset input. to use pin p10 as a port, refer to "how to use external reset input pin as a port". table 8-6 port p1 - - - - p13 p12 p11 p10 secondary function - - - - int1 int0 int5 stop reset tmp89ch42 page 99 ra007
figure 8-4 port p1 tmp89ch42 8. i/o ports 8.3 i/o port registers page 100 ra007 in case of p10 syscr1 syscr1 reset signal (reset 0) reset 0 internal data bus output latch (for each bit) en p1dr write p10 r in2 r in3 r in3 r note1 : r = 100 ? (typ.) note2 : r in2 = 220k ? (typ.) note3 : r in3 = 50k ? (typ.) p1prd read input/output control (for each bit) p1cr write programmable pull-up resistor reset pull-up resistor vdd vdd vdd pull-up control (for each bit) p1pu write internal data bus output latch (for each bit) p1dr write syscr1 syscr3 syscr4 b2h write syscr1 reset signal (reset 2) reset signal (reset 2) p1i r note1 : r = 100 ? (typ.) note2 : r in3 = 50k ? (typ.) note3 : i = 1 ~ 3 int0, int1, int5, stop p1prd read in case of p11 in case of p12 and p13 input/output control (for each bit) p1cr write programmable pull-up resistor vdd vdd pull-up control (for each bit) p1pu write interrupt stop control peripheral functions low-voltage detection reset 1 signal low-voltage detection reset 2 signal watchdog timer reset signal system clock reset signal trimming data reset signal power-on reset signal reset 1 reset 2
port p1 output latch p1dr (0x0001) 7 6 5 4 3 2 1 0 bit symbol - - - - p13 p12 p11 p10 read/write r r r r r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: outputs l level when the output mode is selected. 1: outputs h level when the output mode is selected. port p1 input/output control p1cr (0x0f1b) 7 6 5 4 3 2 1 0 bit symbol - - - - p1cr3 p1cr2 p1cr1 p1cr0 read/write r r r r r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: input mode (port input) int1 (i) int0 (i) int5 (i) stop (i) - 1: output mode (port output) note:symbol "i" means secondary function input port p1 built-in pull-up resistor control p1pu (0x0f28) 7 6 5 4 3 2 1 0 bit symbol - - - - p1pu4 p1pu2 p1pu1 p1pu0 read/write r r r r r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: the built-in pull-up resistor is not connected. 1: the built-in pull-up resistor is connected. (the resistor is connected only when the port is used in the input mode or as the open drain output. under any other conditions, setting to "1" does not make the resistor connected.) port p1 input data p1prd (0x000e) 7 6 5 4 3 2 1 0 bit symbol - - - - p1prd3 p1prd2 p1prd1 p1prd0 read/write r r r r r r r r after reset 0 0 0 0 * * * * function if the port is in the input mode, the contents of the port are read. if not, "0" is read. table 8-7 p1prd read value set condi- tion p1prdi read value p1cri 0 contents of port 1 "0" note 1: * : dont care tmp89ch42 page 101 ra007
note 2: i = 0 to 3 tmp89ch42 8. i/o ports 8.3 i/o port registers page 102 ra007
8.3.3 port p2 (p27 to p20) port p2 is an 8- bit input/output port that can be set to input or output for each bit individually, and it is also used as the serial bus interface input/output, the serial interface input/output, the uart input/output and the on- chip debug function. the output circuit has the p-channel output control function and either the sink open drain output or the c- mos output can be selected. port p2 contains a programmable pull-up resistor on the vdd side. this pull-up resistor can be used when the port is used in the input mode or as a sink open drain output. when this port is used as the serial bus interface, the serial interface or the uart, setting for serial interface selecting function is also needed. for details, refer to "8.4 serial interface selecting function". table 8-8 port p2 p27 p26 p25 p24 p23 p22 p21 p20 secondary function - - sclk0 si0 scl0 so0 sda0 sclk0 si0 rxd0 txd0 so0 txd0 rxd0 tmp89ch42 page 103 ra007
figure 8-5 port p2 tmp89ch42 8. i/o ports 8.3 i/o port registers page 104 ra007 internal data bus 0 1 s output latch (for each bit) p2dr write p2i r r in3 note1 : r = 100 ? (typ.) note2 : r in3 = 50k ? (typ.) sclk0, so0, txd0 sclk0, si0, rxd0 sio0 uart0 peripheral functions sio0 i2c0 peripheral functions p2prd read function control (for each bit) input/output control (for each bit) p2fc write p2cr write output control (for each bit) p2outcr write programmable pull-up resistor vdd vdd pull-up control (for each bit) p2pu write internal data bus 0 1 s output latch (for each bit) p2dr write p2j r note1 : r = 100 ? (typ.) note2 : j = 3, 4 scl0, sda0, so0 scl0, sda0, si0 p2prd read function control (for each bit) input/output control (for each bit) p2fc write p2cr write syscr1 syscr1 reset signal (reset 2) syscr1 syscr1 reset signal (reset 2) note3 : i = 0 to 2, 5 to 7 functions enclosed by the dotted line are for p20, p21,p22 and p25 only.
port p2 output latch p2dr (0x0002) 7 6 5 4 3 2 1 0 bit symbol p27 p26 p25 p24 p23 p22 p21 p20 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: outputs l level when the output mode is selected. 1: outputs h level when the output mode is selected. (serves as hi-z or pull-up depending on settings of p2outcr and p2pu.) port p2 input/output control p2cr (0x0f1c) 7 6 5 4 3 2 1 0 bit symbol p2cr7 p2cr6 p2cr5 p2cr4 p2cr3 p2cr2 p2cr1 p2cr0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: input mode (port input) - - sclk0 (i) si0 (i) - sclk0 (i) rxd0 (i) si0 (i) rxd0 (i) 1: output mode (port output) - - sclk0 (o) scl0 (i/o) sda0 (i/o) so (o) sclk0 (o) txd0(o) txd0 (o) so0 (o) note: symbol "i" means secondary function input. symbol "o" means secondary function output. symbol "i/o" means secondary function input/output tmp89ch42 page 105 ra007
port p2 function control p2fc (0x0f36) 7 6 5 4 3 2 1 0 bit symbol - - p2fc5 p2fc4 p2fc3 p2fc2 p2fc1 p2fc0 read/write r r r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: port function 1: sclk0 (o) scl0 (i/o) sda0 (i/o) so0 (o) sclk0 (o) txd0 (o) txd0 (o) so0 (o) port p2 output control p2outcr (0x0f43) 7 6 5 4 3 2 1 0 bit symbol p2out7 p2out6 p2out5 - - p2out2 p2out1 p2out0 read/write r/w r/w r/w r r r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: c-mos output c-mos output 1: open drain output open drain output port p2 built-in pull-up resistor control p2pu (0x0f29) 7 6 5 4 3 2 1 0 bit symbol p2pu7 p2pu6 p2pu5 - - p2pu2 p2pu1 p2pu0 read/write r/w r/w r/w r r r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: the built-in pull-up resistor is not connec- ted. the built-in pull-up resistor is not connec- ted. 1: the built-in pull-up resistor is connected. (the resistor is connected only when the port is used in the input mode or as the open drain output. under any other condi- tions, setting to "1" does not make the resistor connected.) the built-in pull-up resistor is connected. (the resistor is connected only when the port is used in the input mode or as the open drain output. under any other condi- tions, setting to "1" does not make the resistor connected.) port p2 input data p2prd (0x000f) 7 6 5 4 3 2 1 0 bit symbol p2prd7 p2prd6 p2prd5 p2prd4 p2prd3 p2prd2 p2prd1 p2prd0 read/write r r r r r r r r after reset * * * * * * * * function if the port is used in the input mode or as the open drain output, the contents of the port are read. if not, "0" is read. the contents of the port are read without condition. if the port is used in the input mode or as the open drain output, the contents of the port are read. if not, "0" is read. table 8-9 p2prd read value (p20 to p22, p25 to p27) set condition p2prdi read value p2cri p2outcri 0 * contents of port 1 0 "0" 1 1 contents of port note 1: * : dont care note 2: i = 0 to 2, 5 to 7 tmp89ch42 8. i/o ports 8.3 i/o port registers page 106 ra007
8.3.4 port p4 (p47 to p40) port p4 is an 8-bit input/output port that can be set to input or output for each bit individually, and it is also used as the analog input and the key-on wakeup input. port p4 contains a programmable pull-up resistor on the vdd side. this pull-up resistor can be used when the port is used in the input mode. table 8-10 port p4 p47 p46 p45 p44 p43 p42 p41 p40 secondary function ain7 kwi7 ain6 kwi6 ain5 kwi5 ain4 kwi4 ain3 kwi3 ain2 kwi2 ain1 kwi1 ain0 kwi0 figure 8-6 port p4 tmp89ch42 page 107 ra007 internal data bus output latch (for each bit) p4dr write p4i r r in3 note1 : r = 100 ? (typ.) note2 : r in3 = 50k ? (typ.) note3 : i = 0 to 7 kwii key-on wakeup ad peripheral functions p4prd read aini enable signal kwii enable signal adccr1 function control (for each bit) input/output control (for each bit) p4fc write p4cr write programmable pull-up resistor vdd vdd pull-up control (for each bit) p4pu write reset signal (reset 2) aini syscr1 syscr1
port p4 output latch p4dr (0x0004) 7 6 5 4 3 2 1 0 bit symbol p47 p46 p45 p44 p43 p42 p41 p40 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: outputs l level when the output mode is selected. 1: outputs h level when the output mode is selected. port p4 input/output control p4cr (0x0f1e) 7 6 5 4 3 2 1 0 bit symbol p4cr7 p4cr6 p4cr5 p4cr4 p4cr3 p4cr2 p4cr1 p4cr0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: input mode (port input) ain7 (i) ain6 (i) ain5 (i) ain4 (i) ain3 (i) ain2 (i) ain1 (i) ain0 (i) 1: output mode (port output) note 1: symbol "i" means secondary function input. note 2: when the key-on wakeup input (kwii) is enabled (kwucrm="1"), there is no need to set p4cri. (i=7 to 0, m=1 to 0, n=3 to 0) port p4 function control p4fc (0x0f38) 7 6 5 4 3 2 1 0 bit symbol p4fc7 p4fc6 p4fc5 p4fc4 p4fc3 p4fc2 p4fc1 p4fc0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: port function 1: ain7 (i) ain6 (i) ain5 (i) ain4 (i) ain3 (i) ain2 (i) ain1 (i) ain0 (i) note 1: when the key-on wakeup input (kwii) is enabled, there is no need to set p4fci. port p4 built-in pull-up resistor control p4pu (0x0f2b) 7 6 5 4 3 2 1 0 bit symbol p4pu7 p4pu6 p4pu5 p4pu4 p4pu3 p4pu2 p4pu1 p4pu0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: the built-in pull-up resistor is not connected. 1: the built-in pull-up resistor is connected. ( the resistor is connected only when the key-on wakeup input (kwii) is enabled or the port is used in the input mode (p4fci="0" and p4cri="0"). under any other conditions, setting to "1" does not make the resistor connected.) port p4 input data p4prd (0x0011) 7 6 5 4 3 2 1 0 bit symbol p4prd7 p4prd6 p4prd5 p4prd4 p4prd3 p4prd2 p4prd1 p4prd0 read/write r r r r r r r r after reset * * * * * * * * function if the port is in the input mode, the contents of the port are read. if not, "0" is read. tmp89ch42 8. i/o ports 8.3 i/o port registers page 108 ra007
table 8-11 p4prd read value set condition p4prdi read value p4cri p4fci 0 0 contents of port * 1 "0" 1 * "0" note 1: * : dont care note 2: i = 0 to 7 tmp89ch42 page 109 ra007
8.3.5 port p7 (p77 to p70) port p7 is an 8-bit input/output port that can be set to input or output for each bit individually, and it is also used as the external interrupt input, the divider output and the timer counter input/output. table 8-12 port p7 p77 p76 p75 p74 p73 p72 p71 p70 secondary function int4 int3 int2 dvo ppga1 tca1 ppga0 tca0 ppg01 pwm01 tc01 ppg00 pwm00 tc00 figure 8-7 port p7 tmp89ch42 8. i/o ports 8.3 i/o port registers page 110 ra007 internal data bus 0 1 s output latch (for each bit) p7dr write p7i r note1 : r = 100 ? (typ.) note2 : i = 0 to 7 dvo, ppga1, ppga0, ppg01, ppg00, pwm01, pwm00 int4, int3, int2, tca1, tca0, tc01, tc00 p7prd read function control (for each bit) input/output control (for each bit) p7fc write p7cr write vdd functions enclosed by the dotted line are for p74 to p70 only. divider output external interrupt tca0 tca1 tc00 tc01 peripheral functions syscr1 syscr1 reset signal (reset 2) note3 : nch large current (only p70 to p73) (note3)
port p7 output latch p7dr (0x0007) 7 6 5 4 3 2 1 0 bit symbol p77 p76 p75 p74 p73 p72 p71 p70 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: outputs l level when the output mode is selected 1: outputs h level when the output mode is selected port p7 input/output control p7cr (0x0f21) 7 6 5 4 3 2 1 0 bit symbol p7cr7 p7cr6 p7cr5 p7cr4 p7cr3 p7cr2 p7cr1 p7cr0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: input mode (port input) int4 (i) int3 (i) int2 (i) - tca1 (i) tca0 (i) tc01 (i) tc00 (i) 1: output mode (port output) - - - dvo (o) ppga1 (o) ppga0 (o) ppg01 (o) pwm01 (o) ppg00 (o) pwm00 (o) note:symbol "i" means secondary function input. symbol "o" means secondary function output. port p7 function control p7fc (0x0f3b) 7 6 5 4 3 2 1 0 bit symbol - - - p7fc3 p7fc3 p7fc2 p7fc1 p7fc0 read/write r r r r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: port function 1: dvo (o) ppga1 (o) ppga0 (o) ppg01 (o) pwm01 (o) ppg00 (o) pwm00 (o) port p7 input data p7prd (0x0014) 7 6 5 4 3 2 1 0 bit symbol p7prd7 p7prd6 p7prd5 p7prd4 p7prd3 p7prd2 p7prd1 p7prd0 read/write r r r r r r r r after reset * * * * * * * * function if the port is used in the input mode, the contents of the port are read. if not, "0" is read. table 8-13 p7prd read value set condition p7prdi read value p7cri 0 contents of port 1 "0" note 1: * : dont care note 2: i = 0 to 7 tmp89ch42 page 111 ra007
8.3.6 port p8 (p81 to p80) port p8 is a 2- bit input/output port that can be set to input or output for each bit individually, and it is also used as the timer counter input/output. table 8-14 port p8 p81 p80 secondary function - - - - - - ppg03 pwm03 tc03 ppg02 pwm02 tc02 figure 8-8 port p8 tmp89ch42 8. i/o ports 8.3 i/o port registers page 112 ra007 internal data bus 0 1 s output latch (for each bit) p8dr write p8i r note1 : r = 100 ? (typ.) ppg03, ppg02, pwm03, pwm02 tc03, tc02 p8prd read function control (for each bit) input/output control (for each bit) p8fc write p8cr write vdd functions enclosed by the dotted line are for p81 and p80 only. tc03 tc02 peripheral functions syscr1 syscr1 reset signal (reset 2) note2 : i = 0 to 1
port p8 output latch p8dr (0x0008) 7 6 5 4 3 2 1 0 bit symbol - - - - - - p81 p80 read/write r r r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: outputs l level when the output mode is selected. 1: outputs h level when the output mode is selected. port p8 input/output control p8cr (0x0f22) 7 6 5 4 3 2 1 0 bit symbol - - - - - - p8cr1 p8cr0 read/write r r r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: input mode (port input) tc03 (i) tc02 (i) 1: output mode (port output) ppg03 (o) pwm03 (o) ppg02 (o) pwm02 (o) note:symbol "i" means secondary function input. symbol "o" means secondary function output. port p8 function control p8fc (0x0f3c) 7 6 5 4 3 2 1 0 bit symbol - - - - - - p8fc1 p8fc0 read/write r r r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: port function 1: ppg03 (o) pwm03 (o) ppg02 (o) pwm02 (o) port p8 input data p8prd (0x0015) 7 6 5 4 3 2 1 0 bit symbol - - - - - - p8prd1 p8prd0 read/write r r r r r r r r after reset 0 0 0 0 0 0 * * function if the port is used in the in- put mode, the contents of the port are read. if not, "0" is read. table 8-15 p8prd read value set condition p8prdi read value p8cri 0 contents of port 1 "0" tmp89ch42 page 113 ra007
note 1: * : dont care note 2: i = 0 to 1 tmp89ch42 8. i/o ports 8.3 i/o port registers page 114 ra007
8.3.7 port p9 (p91 to p90) port p9 is a 2- bit input/output port that can be set to input or output for each bit individually, and it is also used as the uart. the output circuit has the p-channel output control function and either the sink open drain output or the c- mos output can be selected. port p9 contains a programmable pull-up resistor on the vdd side. this pull-up resistor can be used when the port is used in the input mode or as a sink open drain output. when this port is used as the uart, setting for the serial interface selecting function is also needed. for details, refer to "8.4 serial interface selecting function". table 8-16 port p9 p91 p90 secondary function - - - - - - rxd1 txd1 txd1 rxd1 figure 8-9 port p9 tmp89ch42 page 115 ra007 internal data bus 0 1 s output latch (for each bit) p9dr write p9i r r in3 note1 : r = 100 ? (typ.) note2 : r in3 = 50k ? (typ.) note3 : i = 0 to 1 txd1 rxd1 p9prd read function control (for each bit) input/output control (for each bit) p9fc write p9cr write output control (for each bit) p9outcr write programmable pull-up resistor vdd vdd pull-up control (for each bit) p9pu write uart1 peripheral functions syscr1 syscr1 reset signal (reset 2)
port p9 output latch p9dr (0x0009) 7 6 5 4 3 2 1 0 bit symbol - - - - - - p91 p90 read/write r r r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: outputs l level when the output mode is selected. 1: outputs h level when the output mode is selected. (serves as hi-z or pull-up depending on settings of p9outcr and p9pu.) port p9 input/output control p9cr (0x0f23) 7 6 5 4 3 2 1 0 bit symbol - - - - - - p9cr1 p9cr0 read/write r r r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: input mode (port input) rxd1 (i) rxd1 (i) 1: output mode (port output) txd1 (o) txd1 (o) note:symbol "i" means secondary function input. symbol "o" means secondary function output. tmp89ch42 8. i/o ports 8.3 i/o port registers page 116 ra007
port p9 function control p9fc (0x0f3d) 7 6 5 4 3 2 1 0 bit symbol - - - - - - p9fc1 p9fc0 read/write r r r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: port function 1: txd1 (o) txd1 (o) port p9 output control p9outcr (0x0f4a) 7 6 5 4 3 2 1 0 bit symbol - - - - - - p9out1 p9out0 read/write r r r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: c-mos output 1: open drain output port p9 built-in pull-up resistor control p9pu (0x0f30) 7 6 5 4 3 2 1 0 bit symbol - - - - - - p9pu1 p9pu0 read/write r r r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 function 0: the built-in pull-up resistor is not connected. 1: note 1 note 1: the built-in pull-up resistor is connected. (the resistor is connected only when the port is used in the input mode or as the open drain output. under any other conditions, setting to "1" does not make the resistor connected.) port p9 input data p9prd (0x0016) 7 6 5 4 3 2 1 0 bit symbol - - - - - - p9prd1 p9prd0 read/write r r r r r r r r after reset 0 0 0 0 0 0 * * function if the port is used in the in- put mode or as the sink open drain output, the con- tents of the port are read. if not, "0" is read. table 8-17 p9prd read value set condition p9prdi read value p9cri p9outcri 0 * contents of port 1 0 "0" 1 1 contents of port note 1: * : dont care note 2: i = 0 to 1 tmp89ch42 page 117 ra007
8.3.8 port pb (pb7 to pb4) port pb is an 4- bit input/output port that can be set to input or output for each bit individually, and it is also used as the serial interface input/output and the uart input/output. the output circuit has the p-channel output control function and either the sink open drain output or the c- mos output can be selected. when this port is used as the serial interface or the uart, setting for serial interface selecting function is also needed. for details, refer to "8.4 serial interface selecting function". table 8-18 port pb pb7 pb6 pb5 pb4 - - - - secondary function - sclk0 si0 rxd0 txd0 so0 txd0 rxd0 - - - - figure 8-10 port pb tmp89ch42 8. i/o ports 8.3 i/o port registers page 118 ra007 internal data bus 0 1 s output latch (for each bit) pbdr write pbi r note1 : r = 100 ? (typ.) note2 : nch large current peripheral functions pbprd read function control (for each bit) input/output control (for each bit) pbfc write pbcr write output control (for each bit) pboutcr write (note2) syscr1 syscr1 reset signal (reset 2) note3 : i = 4 to 7 sio0 uart0 sclk0, si0, rxd0 sclk0, so0, txd0 functions enclosed by the dotted line are for pb6 to pb4 only.
port pb output latch pbdr (0x000b) 7 6 5 4 3 2 1 0 bit symbol pb7 pb6 pb5 pb4 - - - - read/write r/w r/w r/w r/w r r r r after reset 0 0 0 0 0 0 0 0 function 0: outputs l level when the output mode is selected. 1: outputs h level when the output mode is selected. port pb input/output control pbcr (0x0f25) 7 6 5 4 3 2 1 0 bit symbol pbcr7 pbcr6 pbcr5 pbcr4 - - - - read/write r/w r/w r/w r/w r r r r after reset 0 0 0 0 0 0 0 0 function 0: input mode (port input) 1: output mode (port output) port pb function control pbfc (0x0f3f) 7 6 5 4 3 2 1 0 bit symbol - pbfc6 pbfc5 pbfc4 - - - - read/write r r/w r/w r/w r r r r after reset 0 0 0 0 0 0 0 0 function 0: port function 1: sclk0 (o) txd0 (o) txd0 (o) so0 (o) port pb output control pboutcr (0x0f4c) 7 6 5 4 3 2 1 0 bit symbol pbout7 pbout6 pbout5 pbout4 - - - - read/write r/w r/w r/w r/w r r r r after reset 0 0 0 0 0 0 0 0 function 0: c-mos output 1: open drain output tmp89ch42 page 119 ra007
port pb input data pbprd (0x0018) 7 6 5 4 3 2 1 0 bit symbol pbprd7 pbprd6 pbprd5 pbprd4 read/write r r r r r r r r after reset * * * * * * * * function if the port is used in the input mode or as the open drain output, the contents of the port are read. if not, "0" is read. table 8-19 pbprd read value set condition pbprdi read value pbcri pboutcri 0 * contents of port 1 0 "0" 1 1 contents of port note 1: * : dont care note 2: i = 4 to 7 tmp89ch42 8. i/o ports 8.3 i/o port registers page 120 ra007
8.4 serial interface selecting function on the tmp89ch42, the built-in serial interface (sio, uart and i 2 c) communication pins and interrupt source assignment can be changed. two out of three functions, sio0, uart0 and i2c0, can be used at the same time by using this selecting function. the input pins of the 16-bit timer counter a0 input (tca0 input) can be changed by using this selecting function. figure 8-11 serial interface selecting function tmp89ch42 page 121 ra007 uart1 p90 (txd1) p91 (rxd1) uart0 sio0 i2c0 tca0 p20 (txd0 / so0) p21 (rxd0 / si0) p22 (sclk0) sersel sersel 0* 10 selector selector s p23 (sda0 / so0) p24 (scl0 / si0) p25 (sclk0) p72 (tca0) p21 (rxd0) p91 (rxd1) 01 *0 selector s 00 01 10 selector s port port port pb4 (txd0 / so0) pb5 (rxd0 / si0) pb6 (sclk0) sersel s 1 0 port port
serial interface selection control register sersel (0x0fcb) 7 6 5 4 3 2 1 0 bit symbol tca0sel srsel2 srsel0 read/write r/w r/w r r/w r r r/w r/w after reset 0 0 0 0 0 0 0 0 tca0sel 16-bit timer counter a0 input switch- ing 00: 01: 10: 11: p72 input (tca0) p21 input (also used as rxd0) p91 input (also used as rxd1) reserved srsel2 select uart0/sio0 input/output port 0: 1: select p20, p21, p22 select pb4, pb5, pb6 srsel0 serial interface selection 0 00: 01: 10: 11: select uart0, i2c0 select uart0, sio0 select sio0, i2c0 reserved note 1: the operation for changing sersel must be executed while the applicable serial interface and timer counter operations are stopped. if sersel is switched during operation of these peripheral functions, each peripheral function may receive (transmit) unexpected data and operate improperly. note 2: it is recommended to clear the interrupt latch for the applicable serial interface immediately after changing sersel. interrupt latches are common to intrxd and intsio and to intsbi and intsio. therefore, if an interrupt occurs before or after sersel is switched, it is difficult to tell which function has caused the interrupt. uart input/output change control register uatcng (0x0f57) 7 6 5 4 3 2 1 0 bit symbol - - - - - - uat1io uat0io read/write r r r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 rxd pin txd pin uat1io select uart1 input/ output port 0: 1: p91 p90 p90 p91 uat0io select uart0 input/ output port sersel ="0" sersel ="1" sersel ="0" sersel ="1" 0: 1: p21 p20 pb5 pb4 p20 p21 pb4 pb5 note 1: the operation for changing uatcng must be executed while the applicable serial interface operations are stopped. tmp89ch42 8. i/o ports 8.4 serial interface selecting function page 122 ra007
table 8-20 select input/output port and interrupt sersel sersel uatcng port interrupt uart0/sio0 i2c0/sio0 pb4 pb5 pb6 p20 p21 p22 p23 p24 p25 il7 il6 il15 00: 0: 0: note 1 note 1 note 1 txd0 rxd0 note 1 sda0 scl0 note 1 inttxd0 intrxd0 intsbi0 1: rxd0 txd0 1: 0: txd0 rxd0 note 1 note 1 note 1 note 1 1: rxd0 txd0 01: 0: 0: note 1 note 1 note 1 txd0 rxd0 note 1 so0 si0 sclk 0 inttxd0 intrxd0 intsio0 1: rxd0 txd0 1: 0: txd0 rxd0 note 1 note 1 note 1 note 1 1: rxd0 txd0 10: 0: 0 or 1: note 1 note 1 note 1 so0 si0 sclk 0 sda0 scl0 note 1 - intsio0 intsbi0 1: 0 or 1: so0 si0 sclk 0 note 1 note 1 note 1 11: 0 or 1: 0 or 1: reserved note 1: can be used as a port. (set the function register (pxfc) to "0".) tmp89ch42 page 123 ra007
8.5 revision history rev description ra002 "table 8-1 list of i/o ports" added description to p9 port. "table 8-2 list of i/o port settings" added description of uart setting to p90 and p91. " port p2 input/output control" added rxd0(i) to p20. added txd0(o) to p21. "8.3.10 port p8 (p81 to p80)" added description about p8 port. "8.3.11 port p9 (p9741 to p90)" deleted description about serial interface (sio). "8.3.13 port pb (pb75 to pb04)" added detail description about pb port. "8.4 serial interface selecting function" deleted description about sio1 and uart1. "figure 8-17 serial interface selecting function" added pb port. deleted p92 and p94 ports.deleted sio1. " serial interface selection control register" deleted srsel1. revised srsel2 description from "output" to "input/output". deleted table 8-20. ra003 "figure 8-2 port p0 (p00, p01)", "figure 8-3 port p0 (p02, p03)" added damping resistor (ro). "figure 8-4 port p1" deleted stop control from p11 pin input. ra004 defined symbol of programmable pull-up resistor to r in3 . defined symbol of reset pull-up resister to r in2 . "8.3.2 port p1 (p13 to p10)" deleted description of "or as a sink open drain output" "8.3.6 port p4 (p47 to p40)" deleted description of "or as a sink open drain output" ra005 "figure 8-4 port p1" revised reset control signal. ra006 "table 8-2 list of i/o port settings" added new character for pxoutcr. ra007 "figure 8-4 port p1" revised block diagram. added "reset 0 or 2" to reset signal of each port block diagram. tmp89ch42 8. i/o ports 8.5 revision history page 124 ra007
9. special function registers the tmp89ch42 adopts the memory mapped i/o system, and all peripheral hardware data control and transfer operations are performed through the special function registers (sfr). sfr1 is mapped on addresses 0x0000 to 0x003f, sfr2 is mapped on addresses 0x0f00 to 0x0fff, and sfr3 is mapped on addresses 0x0e40 to 0x0ebf. 9.1 sfr1 (0x0000 to 0x003f) table 9-1 sfr1 (0x0000 to 0x003f) address register name address register name 0x0000 p0dr 0x0020 sio0sr 0x0001 p1dr 0x0021 sio0buf 0x0002 p2dr 0x0022 sbi0cr1 0x0003 reserved 0x0023 sbi0cr2/sbi0sr2 0x0004 p4dr 0x0024 i2c0ar 0x0005 reserved 0x0025 sbi0dbr 0x0006 reserved 0x0026 t00reg 0x0007 p7dr 0x0027 t01reg 0x0008 p8dr 0x0028 t00pwm 0x0009 p9dr 0x0029 t01pwm 0x000a reserved 0x002a t00mod 0x000b pbdr 0x002b t01mod 0x000c reserved 0x002c t001cr 0x000d p0prd 0x002d ta0dral 0x000e p1prd 0x002e ta0drah 0x000f p2prd 0x002f ta0drbl 0x0010 reserved 0x0030 ta0drbh 0x0011 p4prd 0x0031 ta0mod 0x0012 reserved 0x0032 ta0cr 0x0013 reserved 0x0033 ta0sr 0x0014 p7prd 0x0034 adccr1 0x0015 p8prd 0x0035 adccr2 0x0016 p9prd 0x0036 adcdrl 0x0017 reserved 0x0037 adcdrh 0x0018 pbprd 0x0038 dvocr 0x0019 reserved 0x0039 tbtcr 0x001a uart0cr1 0x003a eirl 0x001b uart0cr2 0x003b eirh 0x001c uart0dr 0x003c eire 0x001d uart0sr 0x003d eird 0x001e td0buf/rd0buf 0x003e reserved 0x001f sio0cr 0x003f psw note 1: do not access reserved addresses by the program. tmp89ch42 page 125 ra001
9.2 sfr2 (0x0f00 to 0x0fff) table 9-2 sfr2 (0x0f00 to 0x0f7f) address register name address register name address register name address register name 0x0f00 reserved 0x0f20 reserved 0x0f40 reserved 0x0f60 reserved 0x0f01 reserved 0x0f21 p7cr 0x0f41 reserved 0x0f61 reserved 0x0f02 reserved 0x0f22 p8cr 0x0f42 reserved 0x0f62 reserved 0x0f03 reserved 0x0f23 p9cr 0x0f43 p2outcr 0x0f63 reserved 0x0f04 reserved 0x0f24 reserved 0x0f44 reserved 0x0f64 reserved 0x0f05 reserved 0x0f25 pbcr 0x0f45 reserved 0x0f65 reserved 0x0f06 reserved 0x0f26 reserved 0x0f46 reserved 0x0f66 reserved 0x0f07 reserved 0x0f27 p0pu 0x0f47 reserved 0x0f67 reserved 0x0f08 reserved 0x0f28 p1pu 0x0f48 reserved 0x0f68 reserved 0x0f09 reserved 0x0f29 p2pu 0x0f49 reserved 0x0f69 reserved 0x0f0a reserved 0x0f2a reserved 0x0f4a p9outcr 0x0f6a reserved 0x0f0b reserved 0x0f2b p4pu 0x0f4b reserved 0x0f6b reserved 0x0f0c reserved 0x0f2c reserved 0x0f4c pboutcr 0x0f6c reserved 0x0f0d reserved 0x0f2d reserved 0x0f4d reserved 0x0f6d reserved 0x0f0e reserved 0x0f2e reserved 0x0f4e reserved 0x0f6e reserved 0x0f0f reserved 0x0f2f reserved 0x0f4f reserved 0x0f6f reserved 0x0f10 reserved 0x0f30 p9pu 0x0f50 reserved 0x0f70 reserved 0x0f11 reserved 0x0f31 reserved 0x0f51 reserved 0x0f71 reserved 0x0f12 reserved 0x0f32 reserved 0x0f52 reserved 0x0f72 reserved 0x0f13 reserved 0x0f33 reserved 0x0f53 reserved 0x0f73 reserved 0x0f14 reserved 0x0f34 p0fc 0x0f54 uart1cr1 0x0f74 poffcr0 0x0f15 reserved 0x0f35 reserved 0x0f55 uart1cr2 0x0f75 poffcr1 0x0f16 reserved 0x0f36 p2fc 0x0f56 uart1dr 0x0f76 poffcr2 0x0f17 reserved 0x0f37 reserved 0x0f57 uart1sr 0x0f77 poffcr3 0x0f18 reserved 0x0f38 p4fc 0x0f58 td1buf/rd1buf 0x0f78 reserved 0x0f19 reserved 0x0f39 reserved 0x0f59 reserved 0x0f79 reserved 0x0f1a p0cr 0x0f3a reserved 0x0f5a reserved 0x0f7a reserved 0x0f1b p1cr 0x0f3b p7fc 0x0f5b reserved 0x0f7b reserved 0x0f1c p2cr 0x0f3c p8fc 0x0f5c reserved 0x0f7c reserved 0x0f1d reserved 0x0f3d p9fc 0x0f5d reserved 0x0f7d reserved 0x0f1e p4cr 0x0f3e reserved 0x0f5e reserved 0x0f7e reserved 0x0f1f reserved 0x0f3f pbfc 0x0f5f reserved 0x0f7f reserved note 1: do not access reserved addresses by the program. tmp89ch42 9. special function registers 9.2 sfr2 (0x0f00 to 0x0fff) page 126 ra001
table 9-3 sfr2 (0x0f80 to 0x0fff) address register name address register name address register name address register name 0x0f80 reserved 0x0fa0 reserved 0x0fc0 reserved 0x0fe0 ill 0x0f81 reserved 0x0fa1 reserved 0x0fc1 reserved 0x0fe1 ilh 0x0f82 reserved 0x0fa2 reserved 0x0fc2 reserved 0x0fe2 ile 0x0f83 reserved 0x0fa3 reserved 0x0fc3 reserved 0x0fe3 ild 0x0f84 reserved 0x0fa4 reserved 0x0fc4 kwucr0 0x0fe4 reserved 0x0f85 reserved 0x0fa5 reserved 0x0fc5 kwucr1 0x0fe5 reserved 0x0f86 reserved 0x0fa6 reserved 0x0fc6 vdcr1 0x0fe6 reserved 0x0f87 reserved 0x0fa7 reserved 0x0fc7 vdcr2 0x0fe7 reserved 0x0f88 t02reg 0x0fa8 ta1dral 0x0fc8 rtccr 0x0fe8 reserved 0x0f89 t03reg 0x0fa9 ta1drah 0x0fc9 reserved 0x0fe9 reserved 0x0f8a t02pwm 0x0faa ta1drbl 0x0fca reserved 0x0fea reserved 0x0f8b t03pwm 0x0fab ta1drbh 0x0fcb sersel 0x0feb reserved 0x0f8c t02mod 0x0fac ta1mod 0x0fcc irstsr 0x0fec reserved 0x0f8d t03mod 0x0fad ta1cr 0x0fcd wuccr 0x0fed reserved 0x0f8e t023cr 0x0fae ta1sr 0x0fce wucdr 0x0fee reserved 0x0f8f reserved 0x0faf reserved 0x0fcf cgcr 0x0fef reserved 0x0f90 reserved 0x0fb0 reserved 0x0fd0 reserved 0x0ff0 ilprs1 0x0f91 reserved 0x0fb1 reserved 0x0fd1 reserved 0x0ff1 ilprs2 0x0f92 reserved 0x0fb2 reserved 0x0fd2 reserved 0x0ff2 ilprs3 0x0f93 reserved 0x0fb3 reserved 0x0fd3 reserved 0x0ff3 ilprs4 0x0f94 reserved 0x0fb4 reserved 0x0fd4 wdctr 0x0ff4 ilprs5 0x0f95 reserved 0x0fb5 reserved 0x0fd5 wdcdr 0x0ff5 ilprs6 0x0f96 reserved 0x0fb6 reserved 0x0fd6 wdcnt 0x0ff6 reserved 0x0f97 reserved 0x0fb7 reserved 0x0fd7 wdst 0x0ff7 reserved 0x0f98 reserved 0x0fb8 reserved 0x0fd8 eintcr1 0x0ff8 reserved 0x0f99 reserved 0x0fb9 reserved 0x0fd9 eintcr2 0x0ff9 reserved 0x0f9a reserved 0x0fba reserved 0x0fda eintcr3 0x0ffa reserved 0x0f9b reserved 0x0fbb reserved 0x0fdb eintcr4 0x0ffb reserved 0x0f9c reserved 0x0fbc reserved 0x0fdc syscr1 0x0ffc reserved 0x0f9d reserved 0x0fbd reserved 0x0fdd syscr2 0x0ffd reserved 0x0f9e reserved 0x0fbe reserved 0x0fde syscr3 0x0ffe reserved 0x0f9f reserved 0x0fbf reserved 0x0fdf syscr4/syssr4 0x0fff reserved note 1: do not access reserved addresses by the program. tmp89ch42 page 127 ra001
9.3 sfr3 (0x0e40 to 0x0eff) table 9-4 sfr3 (0x0e40 to 0x0ebf) address register name address register name address register name address register name 0x0e40 reserved 0x0e60 reserved 0x0e80 reserved 0x0ea0 reserved 0x0e41 reserved 0x0e61 reserved 0x0e81 reserved 0x0ea1 reserved 0x0e42 reserved 0x0e62 reserved 0x0e82 reserved 0x0ea2 reserved 0x0e43 reserved 0x0e63 reserved 0x0e83 reserved 0x0ea3 reserved 0x0e44 reserved 0x0e64 reserved 0x0e84 reserved 0x0ea4 reserved 0x0e45 reserved 0x0e65 reserved 0x0e85 reserved 0x0ea5 reserved 0x0e46 reserved 0x0e66 reserved 0x0e86 reserved 0x0ea6 reserved 0x0e47 reserved 0x0e67 reserved 0x0e87 reserved 0x0ea7 reserved 0x0e48 reserved 0x0e68 reserved 0x0e88 reserved 0x0ea8 reserved 0x0e49 reserved 0x0e69 reserved 0x0e89 reserved 0x0ea9 reserved 0x0e4a reserved 0x0e6a reserved 0x0e8a reserved 0x0eaa reserved 0x0e4b reserved 0x0e6b reserved 0x0e8b reserved 0x0eab reserved 0x0e4c reserved 0x0e6c reserved 0x0e8c reserved 0x0eac reserved 0x0e4d reserved 0x0e6d reserved 0x0e8d reserved 0x0ead reserved 0x0e4e reserved 0x0e6e reserved 0x0e8e reserved 0x0eae reserved 0x0e4f reserved 0x0e6f reserved 0x0e8f reserved 0x0eaf reserved 0x0e50 reserved 0x0e70 reserved 0x0e90 reserved 0x0eb0 reserved 0x0e51 reserved 0x0e71 reserved 0x0e91 reserved 0x0eb1 reserved 0x0e52 reserved 0x0e72 reserved 0x0e92 reserved 0x0eb2 reserved 0x0e53 reserved 0x0e73 reserved 0x0e93 reserved 0x0eb3 reserved 0x0e54 reserved 0x0e74 reserved 0x0e94 reserved 0x0eb4 reserved 0x0e55 reserved 0x0e75 reserved 0x0e95 reserved 0x0eb5 reserved 0x0e56 reserved 0x0e76 reserved 0x0e96 reserved 0x0eb6 reserved 0x0e57 uatcng 0x0e77 reserved 0x0e97 reserved 0x0eb7 reserved 0x0e58 reserved 0x0e78 reserved 0x0e98 reserved 0x0eb8 reserved 0x0e59 reserved 0x0e79 reserved 0x0e99 reserved 0x0eb9 reserved 0x0e5a reserved 0x0e7a reserved 0x0e9a reserved 0x0eba reserved 0x0e5b reserved 0x0e7b reserved 0x0e9b reserved 0x0ebb reserved 0x0e5c reserved 0x0e7c reserved 0x0e9c reserved 0x0ebc reserved 0x0e5d reserved 0x0e7d reserved 0x0e9d reserved 0x0ebd reserved 0x0e5e reserved 0x0e7e reserved 0x0e9e reserved 0x0ebe reserved 0x0e5f reserved 0x0e7f reserved 0x0e9f reserved 0x0ebf reserved note 1: do not access reserved addresses by the program. tmp89ch42 9. special function registers 9.3 sfr3 (0x0e40 to 0x0eff) page 128 ra001
table 9-5 sfr3 (0x0ec0 to 0x0eff) address register name address register name address register name address register name 0x0ec0 reserved 0x0ed0 reserved 0x0ee0 reserved 0x0ef0 reserved 0x0ec1 reserved 0x0ed1 reserved 0x0ee1 reserved 0x0ef1 reserved 0x0ec2 reserved 0x0ed2 reserved 0x0ee2 reserved 0x0ef2 reserved 0x0ec3 reserved 0x0ed3 reserved 0x0ee3 reserved 0x0ef3 reserved 0x0ec4 reserved 0x0ed4 reserved 0x0ee4 reserved 0x0ef4 reserved 0x0ec5 reserved 0x0ed5 reserved 0x0ee5 reserved 0x0ef5 reserved 0x0ec6 reserved 0x0ed6 reserved 0x0ee6 reserved 0x0ef6 reserved 0x0ec7 reserved 0x0ed7 reserved 0x0ee7 reserved 0x0ef7 reserved 0x0ec8 reserved 0x0ed8 reserved 0x0ee8 reserved 0x0ef8 reserved 0x0ec9 reserved 0x0ed9 reserved 0x0ee9 reserved 0x0ef9 reserved 0x0eca reserved 0x0eda reserved 0x0eea reserved 0x0efa reserved 0x0ecb reserved 0x0edb reserved 0x0eeb reserved 0x0efb reserved 0x0ecc reserved 0x0edc reserved 0x0eec reserved 0x0efc reserved 0x0ecd reserved 0x0edd reserved 0x0eed reserved 0x0efd reserved 0x0ece reserved 0x0ede reserved 0x0eee reserved 0x0efe reserved 0x0ecf reserved 0x0edf reserved 0x0eef reserved 0x0eff reserved note 1: do not access reserved addresses by the program. tmp89ch42 page 129 ra001
tmp89ch42 9. special function registers 9.3 sfr3 (0x0e40 to 0x0eff) page 130 ra001
10. low power consumption function for peripherals the tmp89ch42 has low power consumption registers (poffcrn) that save power when specific peripheral functions are unused. each bit of the low power consumption registers can be set to enable or disable each peripheral function. (n = 0, 1, 2, 3) the basic clock supply to each peripheral function is disabled for power saving, by setting the corresponding bit of the low power consumption registers (poffcrn) to "0". (the disabled peripheral functions become unavailable.) the basic clock supply to each peripheral function is enabled and the function becomes available by setting the corre- sponding bit of the low power consumption registers (poffcrn) to "1". after reset, the low power consumption registers (poffcrn) are initialized to "0", and thus the peripheral functions are unavailable. when each peripheral function is used for the first time, be sure to set the corresponding bit of the low power consumption registers (poffcrn) to "1" in the initial settings of the program (before operating the control register for the peripheral function). when a peripheral function is operating, the corresponding bit of the low power consumption registers (poffcrn) must not be changed to "0". if it is changed, the peripheral function may operate unexpectedly. tmp89ch42 page 131 ra001
10.1 control the low power consumption function is controlled by the low power consumption registers (poffcrn). (n = 0, 1, 2, 3) low power consumption register 0 poffcr0 7 6 5 4 3 2 1 0 (0x0f74) bit symbol - - tc023en tc001en - - tca1en tca0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 tc023en tc02,03 control 0 1 disable enable tc001en tc00,01 control 0 1 disable enable tca1en tca1 control 0 1 disable enable tca0en tca0 control 0 1 disable enable low power consumption register 1 poffcr1 7 6 5 4 3 2 1 0 (0x0f75) bit symbol - - - sbi0en - - uart1en uart0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 sbi0en i2c0 control 0 1 disable enable uart1en uart1 control 0 1 disable enable uart0en uart0 control 0 1 disable enable low power consumption register 2 poffcr2 7 6 5 4 3 2 1 0 (0x0f76) bit symbol - - rtcen - - - - sio0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 rtcen rtc control 0 1 disable enable sio0en sio0 control 0 1 disable enable tmp89ch42 10. low power consumption function for peripherals 10.1 control page 132 ra001
low power consumption register 3 poffcr3 7 6 5 4 3 2 1 0 (0x0f77) bit symbol - - int5en int4en int3en int2en int1en int0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 int5en int5 control 0 1 disable enable int4en int4 control 0 1 disable enable int3en int3 control 0 1 disable enable int2en int2 control 0 1 disable enable int1en int1 control 0 1 disable enable int0en int0 control 0 1 disable enable tmp89ch42 page 133 ra001
tmp89ch42 10. low power consumption function for peripherals 10.1 control page 134 ra001
11. divider output ( dvo) this function outputs approximately 50% duty pulses that can be used to drive the piezoelectric buzzer or other device. 11.1 configuration figure 11-1 divider output tmp89ch42 page 135 ra001 dvocr selector dvoen dvo pin dvock 2 a b c y d s fcgck/2 12 or fs/2 5 fcgck/2 11 or fs/2 4 fcgck/2 10 or fs/2 3 fcgck/2 9
11.2 control the divider output is controlled by the divider output control register (dvocr). divider output control register dvocr (0x0038) 7 6 5 4 3 2 1 0 bit symbol - - - - - dv0en dvock read/write r r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 dvoen enables/disables the divider output 0: disable the divider output 1: enable the divider output dvock selects the divider output frequency unit: [hz] normal 1/2, idle 1/2 mode slow1/2 sleep1 mode dv9ck=0 dv9ck=1 00 fcgck/2 12 fs/2 5 fs/2 5 01 fcgck/2 11 fs/2 4 fs/2 4 10 fcgck/2 10 fs/2 3 fs/2 3 11 fcgck/2 9 reserved reserved note 1: fcgck: gear clock [hz], fs: low-frequency clock [hz] note 2: dvocr is cleared to "0" when the operation is switched to stop or idle0/sleep0 mode. dvocr holds the value. note 3: when syscr1 is "1" in the normal 1/2 or idle 1/2 mode, the dvo frequency is subject to some fluctuations to synchronize fs and fcgck. note 4: bits 7 to 3 of dvocr are read as "0". tmp89ch42 11. divider output ( 11.2 control page 136 ra001
11.3 function select the divider output frequency at dvocr. the divider output is enabled by setting dvocr to "1". then, the rectangular waves selected by dvocr is output from dvo pin. it is disabled by clearing dvovr to "0". and dvo pin keeps "h" level. when the operation is changed to stop or idle0/sleep0 mode, dvocr is cleared to "0" and the dvo pin outputs the "h" level. the divider output source clock operates, regardless of the value of dvocr. therefore, the frequency of the first divider output after dvocr is set to "1" is not the frequency set at dvocr. when the operation is changed to the software, stop or idle0/sleep0 mode is activated and dvocr is cleared to "0", the frequency of the divider output is not the frequency set at dvocr. figure 11-2 divider output timing when the operation is changed from normal mode to slow mode or from slow mode to normal mode, the divider output frequency does not reach the expected value due to synchronization of the gear clock (fcgck) and the low-frequency clock (fs). example: 2.441 khz pulse output (fcgck = 10.0 mhz) ld (dvocr), 0y00000100 ; dvock "00", dvoen "1" table 11-1 divider output frequency (example: fcgck = 10.0 mhz, fs = 32.768 khz) dvock divider output frequency [hz] normal 1/2, idle 1/2 mode slow1/2, sleep1 mode dv9ck = 0 dv9ck = 1 00 2.441 k 1.024 k 1.024 k 01 4.883 k 2.048 k 2.048 k 10 9.766 k 4.096 k 4.096 k 11 19.531 k reserved reserved tmp89ch42 page 137 ra001 tbtcr divider output timing chart dvo output
11.4 revision history rev description ra001 deleted sleep2 description. tmp89ch42 11. divider output ( 11.4 revision history page 138 ra001
12. time base timer (tbt) the time base timer generates the time base for key scanning, dynamic display and other processes. it also provides a time base timer interrupt (inttbt) in a certain cycle. 12.1 time base timer 12.1.1 configuration figure 12-1 time base timer configuration 12.1.2 control the time base timer is controlled by the time base timer control register (tbtcr). time base timer control register tbtcr (0x0039) 7 6 5 4 3 2 1 0 bit symbol - - - - tbten tbtck read/write r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 tbten enables/disables the time base tim- er interrupt requests 0: disables generation of interrupt request signals 1: enables generation of interrupt request signals tbtck selects the time base timer interrupt frequency unit: [hz] tbtck normal 1/2, idle 1/2 mode slow1/2, sleep1 mode dv9ck = 0 dv9ck = 1 000 fcgck/2 22 fs/2 15 fs/2 15 001 fcgck/2 20 fs/2 13 fs/2 13 010 fcgck/2 15 fs/2 8 reserved 011 fcgck/2 13 fs/2 6 reserved 100 fcgck/2 12 fs/2 5 reserved 101 fcgck/2 11 fs/2 4 reserved 110 fcgck/2 10 fs/2 3 reserved 111 fcgck/2 8 reserved reserved note 1: fcgck : gear clock [hz], fs : low-frequency clock [hz] note 2: when the operation is changed to the stop mode, tbtcr is cleared to "0" and tbtcr maintains the value. note 3: tbtcr should be set when tbtcr is "0". tmp89ch42 page 139 ra001 falling edge detector tbtcr source clock tbten tbtck 3 inttbt interrupt request selector idle0, sleep0 release request fcgck/2 22 or fs/2 15 fcgck/2 20 or fs/2 13 fcgck/2 15 or fs/2 8 fcgck/2 13 or fs/2 6 fcgck/2 12 or fs/2 5 fcgck/2 11 or fs/2 4 fcgck/2 10 or fs/2 3 fcgck/2 8
note 4: when syscr1 is "1" in the normal 1/2 or idle1/2 mode, the interrupt request is subject to some fluctuations to synchronize fs and fcgck. note 5: bits 7 to 4 of tbtcr are read as "0". 12.1.3 functions select the source clock frequency for the time base timer by tbtcr. tbtcr should be changed when tbtcr is "0". otherwise, the inttbt interrupt request is generated at unexpected timing. setting tbtcr to "1" causes interrupt request signals to occur at the falling edge of the source clock. when tbtcr is cleared to "0", no interrupt request signal will occur. when the operation is changed to the stop mode, tbtcr is cleared to "0". the source clock of the time base timer operates regardless of the tbtcr value. a time base timer interrupt is generated at the first falling edge of the source clock after a time base timer interrupt request is enabled. therefore, the period from when the time tbtcr is set to "1" to the time when the first interrupt request occurs is shorter than the frequency period set at tbtcr. figure 12-2 time base timer interrupt when the operation is changed from normal mode to slow mode or from slow mode to normal mode, the interrupt request will not occur at the expected timing due to synchronization of the gear clock (fcgck) and the low-frequency clock (fs). it is recommened that the operation mode is changed when tbtcr is "0". table 12-1 time base timer interrupt frequency (example: when fcgck = 10 .0 mhz and fs = 32.768 khz) tbtck time base timer interrupt frequency [hz] normal1/2, idle1/2 mode normal1/2, idle1/2 mode slow1/2, sleep1 mode dv9ck = 0 dv9ck = 1 000 2.38 1 1 001 9.54 4 4 010 305.18 128 reserved 011 1220.70 512 reserved 100 2441.41 1024 reserved 101 4882.81 2048 reserved 110 9765.63 4096 reserved 111 39062.5 reserved reserved tmp89ch42 12. time base timer (tbt) 12.1 time base timer page 140 ra001 source clock time base timer enable interrupt period tbtcr inttbt interrupt request
example: set the time base timer interrupt frequency to fcgck/2 15 [hz] and enable interrupts. di ; imf 0 set (eirl). 5 ; set the interrupt enable register ei ; imf 1 ld (tbtcr), 0y00000010 ; set the interrupt frequency ld (tbtcr), 0y00001010 ; enable generation of interrupt request signals tmp89ch42 page 141 ra001
12.2 revision history rev description ra001 deleted sleep2 description tmp89ch42 12. time base timer (tbt) 12.2 revision history page 142 ra001
13. 16-bit timer counter (tca) the tmp89ch42 contains 2 channels of high-performance 16-bit timer counters (tca). this chapter describes the 16-bit timer counter a0. for the 16-bit timer counter a1, replace the sfr addresses and pin names, as shown in table 13-1 and table 13-2. table 13-1 sfr address assignment taxdral (address) taxdrah (address) taxdrbl (address) taxdrbh (address) taxmod (address) taxcr (address) taxsr (address) low power consump- tion register timer counter a0 ta0dral (0x002d) ta0drah (0x002e) ta0drbl (0x002f) ta0drbh (0x0030) ta0mod (0x0031) ta0cr (0x0032) ta0sr (0x0033) poffcr0 timer counter a1 ta1dral (0x0fa8) ta1drah (0x0fa9) ta1drbl (0x0faa) ta1drbh (0x0fab) ta1mod (0x0fac) ta1cr (0x0fad) ta1sr (0x0fae) poffcr0 table 13-2 pin names timer input pin ppg output pin timer counter a0 tca0 pin ppga0 pin timer counter a1 tca1 pin ppga1 pin tmp89ch42 page 143 rb002
13.1 configuration figure 13-1 timer counter a0 tmp89ch42 13. 16-bit timer counter (tca) 13.1 configuration page 144 rb002 ta0drah selector selector selector selector overflow match detection pulse width measurement mode pulse width measurement mode ppg mode reading and writing of ta0drah reading and writing of ta0dral ta0dral temporary buffer double buffer (16 bits) 16-bit up counter internal bus internal bus 01 0 0 0 1 1 1 comparator inttca0 interrupt request match detection count up count clear clear ta0s ta0drbh ta0mod ta0cr ta0sr decorder ta0ove ppga0 output timer f/f ta0ted edge detection 2 edge detection 1 edge detection 2 edge detection 1 edge detection 1 edge detection 2 edge detection 2 rising falling edge detection 1 falling rising ta0ted 0 1 edge detection 1 edge detection 2 en ta0cap ta0nc fcgck/2 10 or fs/2 3 fcgck/2 6 fcgck/2 2 fcgck/2 e a b c d 1 0 2 ta0ck ta0m ta0dbe ta0ted ta0mett ta0nc ta0ove ta0cap ta0mppg ta0cpfb ta0cpfa ta0ovf ta0s ta0tff y y s0 s1 s selector selector selector window mode event counter mode ppg mode tca0 pin input selector reading and writing of ta0drbh reading and writing of ta0drbl ta0drbl temporary buffer double buffer (16 bits) 01 0 0 0 1 1 1 external trigger input selection auto capture control capture control timer start control external trigger timer mode pulse width measurement mode capture control noise canceller 2 3 comparator ta0dbe ppg mode ta0dbe
13.2 control timer counter a0 is controlled by the low power consumption register (poffcr 0 ), the timer counter a0 mode register (ta0mod), the timer counter a0 control register (ta0cr) and two 16-bit timer a0 registers (ta0dra and ta0drb). low power consumption register 0 poffcr0 7 6 5 4 3 2 1 0 (0x0f74) bit symbol - - tc023en tc001en - - tca1en tca0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 tc023en tc02,03 control 0 1 disable enable tc001en tc00,01 control 0 1 disable enable tca1en tca1 control 0 1 disable enable tca0en tca0 control 0 1 disable enable tmp89ch42 page 145 rb002
timer counter a0 mode register ta0mod 7 6 5 4 3 2 1 0 (0x0031) bit symbol ta0dbe ta0ted ta0mcap ta0mett ta0ck ta0m read/write r/w r/w r/w r/w r/w after reset 1 0 0 0 0 0 0 0 ta0dbe double buffer control 0 1 disable the double buffer enable the double buffer ta0ted external trigger input selection 0 1 rising edge/h level falling edge/l level ta0mcap pulse width measurement mode control 0 1 double edge capture single edge capture ta0mett external trigger timer mode control 0 1 trigger start trigger start & stop ta0ck timer counter 1 source clock selec- tion normal 1/2 or idle 1/2 mode slow1/2 or sleep1 mode syscr1 ="0" syscr1 ="1" 00 fcgck/2 10 fs/2 3 fs/2 3 01 fcgck/2 6 fcgck/2 6 - 10 fcgck/2 2 fcgck/2 2 - 11 fcgck/2 fcgck/2 - ta0m timer counter 1 operation mode se- lection 000 timer mode 001 timer mode 010 event counter mode 011 ppg output mode (software start) 100 external trigger timer mode 101 window mode 110 pulse width measurement mode 111 reserved note 1: fcgck, gear clock [hz]; fs, low-frequency clock [hz] note 2: set ta0mod in the stopped state (ta0cr="0"). writing to ta0mod is invalid during the operation (ta0cr="1"). tmp89ch42 13. 16-bit timer counter (tca) 13.2 control page 146 rb002
timer counter a0 control register ta0cr 7 6 5 4 3 2 1 0 (0x0032) bit symbol ta0ove ta0tff ta0nc - - ta0acap ta0mppg ta0s read/write r/w r/w r/w r r r/w r/w after reset 0 1 0 0 0 0 0 0 ta0ove overflow interrupt control 0 generate no inttca0 interrupt request when the counter overflow oc- curs. 1 generate an inttca0 interrupt request when the counter overflow oc- curs. ta0tff timer f/f control 0 1 clear set ta0nc noise canceller sampling interval setting normal 1/2 or idle 1/2 mode slow1/2 or sleep1 mode 00 no noise canceller no noise canceller 01 fcgck/2 - 10 fcgck/2 2 - 11 fcgck/2 8 fs/2 ta0acap auto capture function 0 1 disable the auto capture enable the auto capture ta0mppg ppg output control 0 1 continuous one-shot ta0s timer counter a start control 0 1 stop & counter clear start note 1: the auto capture can be used only in the timer, event counter, external trigger timer and window modes. note 2: set ta0tff, ta0ove and ta0nc in the stopped state (ta0s="0"). writing is invalid during the operation (ta0s="1"). note 3: when the stop mode is started, the start control (ta0s) is automatically cleared to "0" and the timer stops. set ta0s again to use the timer counter after the release of the stop mode. note 4: when a read instruction is executed on ta0cr, bits 3 and 2 are read as "0". note 5: do not set ta0nc to "01" or "10" when the slow 1/2 or sleep 1 mode is used. setting ta0nc to "01" or "10" stops the noise canceller and no signal is input to the timer. tmp89ch42 page 147 rb002
timer counter a0 status register ta0sr 7 6 5 4 3 2 1 0 (0x0033) bit symbol ta0ovf - - - - - ta0cpfa ta0cpfb read/write r r r r r r r r after reset 0 0 0 0 0 0 0 0 ta0ovf overflow flag 0 1 no overflow has occurred. at least an overflow has occurred. ta0cpfa capture completion flag a 0 no capture operation has been executed. 1 at least a pulse width capture has been executed in the double-edge capture. ta0cpfb capture completion flag b 0 no capture operation has been executed. 1 at least a capture operation has been executed in the single-edge cap- ture. at least a pulse duty width capture has been executed in the double- edge capture. note 1: ta0ovf, ta0cpfa and ta0cpfb are cleared to "0" automatically after ta0sr is read. writing to ta0sr is invalid. note 2: when a read instruction is executed on ta0sr, bits 6 to 2 are read as "0". tmp89ch42 13. 16-bit timer counter (tca) 13.2 control page 148 rb002
timer counter a0 register ah ta0drah 15 14 13 12 11 10 9 8 (0x002e) bit symbol ta0drah read/write r/w after reset 1 1 1 1 1 1 1 1 timer counter a0 register al ta0dral 7 6 5 4 3 2 1 0 (0x002d) bit symbol ta0dral read/write r/w after reset 1 1 1 1 1 1 1 1 timer counter a0 register bh ta0drbh 15 14 13 12 11 10 9 8 (0x0030) bit symbol ta0drbh read/write r/w after reset 1 1 1 1 1 1 1 1 timer counter a0 register bl ta0drbl 7 6 5 4 3 2 1 0 (0x002f) bit symbol ta0drbl read/write r/w after reset 1 1 1 1 1 1 1 1 note 1: when a write instruction is executed on ta0dral (ta0drbl), the set value does not become effective immediately, but is temporarily stored in the temporary buffer. subsequently, when a write instruction is executed on the higher-level register, ta0drah (ta0drbh), the 16-bit set values are collectively stored in the double buffer or ta0dral/h. when setting data to the timer counter a0 register, be sure to write the data into the lower level register and the higher level in this order. note 2: the timer counter a0 register is not writable in the pulse width measurement mode. tmp89ch42 page 149 rb002
13.3 low power consumption function timer counter a0 has the low power consumption register (poffcr 0 ) that saves power consumption when the timer is not used. setting poffcr0 to "0" disables the basic clock supply to timer counter a0 to save power. note that this makes the timer unusable. setting poffcr 0 to "1" enables the basic clock supply to timer counter a0 and allows the timer to operate. after reset, poffcr 0 is initialized to "0", and this makes the timer unusable. when using the timer for the first time, be sure to set poffcr 0 to "1" in the initial setting of the program (before the timer control register is operated). do not change poffcr0 to "0" during the timer operation. otherwise timer counter a0 may operate unexpectedly. tmp89ch42 13. 16-bit timer counter (tca) 13.3 low power consumption function page 150 rb002
13.4 timer function timer counter a0 has six types of operation modes; timer, external trigger timer, event counter, window, pulse width measurement and programmable pulse generate (ppg) output modes. 13.4.1 timer mode in the timer mode, the up-counter counts up using the internal clock, and interrupts can be generated regularly at specified times. 13.4.1.1 setting setting the operation mode selection ta0mod to "000" or "001" activates the timer mode. select the source clock at ta0mod. setting ta0cr to "1" starts the timer operation. after the timer is started, writing to ta0mod and ta0cr becomes invalid. be sure to complete the required mode settings before starting the timer. table 13-3 timer mode resolution and maximum time setting ta0mod source clock [hz] resolution maximum time setting normal 1/2 or idle 1/2 mode slow1/2 or sleep1 mode fcgck=10mhz fs=32.768khz fcgck=10mhz fs=32.768khz syscr1 = "0" syscr1 = "1" 00 fcgck/2 10 fs/2 3 fs/2 3 102.4s 244.1s 6.7s 16s 01 fcgck/2 6 fcgck/2 6 - 6.4s - 419.4ms - 10 fcgck/2 2 fcgck/2 2 - 400ns - 26.2ms - 11 fcgck/2 fcgck/2 - 200ns - 13.1ms - 13.4.1.2 operation setting ta0cr to "1" allows the 16-bit up counter to increment based on the selected internal source clock. when a match between the up-counter value and the value set to timer register a (ta0dra) is detected, an inttca0 interrupt request is generated and the up counter is cleared to "0x0000". after being cleared, the up counter continues counting. setting ta0cr to "0" during the timer operation causes the up counter to stop counting and be cleared to "0x0000". 13.4.1.3 auto capture the latest contents of the up counter can be taken into timer register b (ta0drb) by setting ta0cr to "1" (auto capture function). when ta0cr is "1", the current contents of the up counter can be read by reading ta0drbl. ta0drbh is loaded at the same time as ta0drbl is read. therefore, when reading the captured value, be sure to read ta0drbl and ta0drbh in this order. (the capture time is the timing when ta0drbl is read.) the auto capture function can be used whether the timer is operating or stopped. when the timer is stopped, ta0drbl is read as "0x00". ta0drbh keeps the captured value after the timer stops, but it is cleared to "0x00" when ta0drbl is read while the timer is stopped. if the timer is started with ta0cr written to "1", the auto capture is enabled immediately after the timer is started. note 1: the value set to ta0cr cannot be changed at the same time as ta0cr is rewritten from "1" to "0". (this setting is invalid.) tmp89ch42 page 151 rb002
13.4.1.4 register buffer configuration (1) temporary buffer the tmp89ch42 contains an 8-bit temporary buffer. when a write instruction is executed on ta0dral, the data is first stored into this temporary buffer, whether the double buffer is enabled or disabled. subsequently, when a write instruction is executed on ta0drah, the set value is stored into the double buffer or ta0drah. at the same time, the set value in the temporary buffer is stored into the double buffer or ta0dral. (this structure is designed to enable the set values of the lower-level and higher-level registers simultaneously.) therefore, when setting data to ta0dra, be sure to write the data into ta0dral and ta0drah in this order. see figure 13-1 for the temporary buffer configuration. (2) double buffer in the tmp89ch42, the double buffer can be used by setting ta0cr. setting ta0cr to "0" disables the double buffer. setting ta0cr to "1" enables the double buffer. see figure 13-1 for the double buffer configuration. - when the double buffer is enabled when a write instruction is executed on ta0drah during the timer operation, the set value is first stored into the double buffer, and ta0drah/l are not updated immediately. ta0drah/l compare the up counter value to the last set values. if the values are matched, an inttca0 interrupt request is generated and the double buffer set value is stored in ta0drah/l. subsequently, the match detection is executed using a new set value. when a read instruction is executed on ta0drah/l, the double buffer value (the last set value) is read, rather than the ta0drah/l values (the current effective values). when a write instruction is executed on ta0drah/l while the timer is stopped, the set value is immediately stored into both the double buffer and ta0drah/l. - when the double buffer is disabled when a write instruction is executed on ta0drah during the timer operation, the set value is immediately stored into ta0drah/l. subsequently, the match detection is executed using a new set value. if the values set to ta0drah/l are smaller than the up counter value, the match detection is executed using a new set value after the up counter overflows. therefore, the interrupt request interval may be longer than the selected time. if that is a problem, enable the double buffer. when a write instruction is executed on ta0drah/l while the timer is stopped, the set value is immediately stored into ta0drah/l. tmp89ch42 13. 16-bit timer counter (tca) 13.4 timer function page 152 rb002
figure 13-2 timer mode timing chart tmp89ch42 page 153 rb002 source clock counter timer start 1 0 n m write to ta0dral write to ta0drah ta0dral match detection write n write s write m write r reflected by writing to ta0drah reflected by writing to ta0drah reflected by an interrupt reflected at the same time as data is written into ta0drah while the timer is stopped counter clear inttca0 interrupt request 234 mn-1 mn 01 rs 01 220 3 ta0drah ta0cr s r timer stop match detection counter clear rs-1 ta0mod when the double buffer is disabled (ta0mod=?0?) source clock counter timer start 1 0 n m write to ta0dral write to ta0drah ta0dral match detection write n write s write m write r counter clear inttca0 interrupt request 234 mn-1 mn 01 mn 01 23 ta0drah ta0cr s r n temporary buffer (8 bits) s n temporary buffer (8 bits) s mn double buffer (16 bits) rs match detection match detection counter clear 01 mn-1 rs rs-1 ta0mod when the double buffer is enabled (ta0mod=?1?)
figure 13-3 timer mode timing chart (auto capture) tmp89ch42 13. 16-bit timer counter (tca) 13.4 timer function page 154 rb002 source clock counter timer start ta0drbh is updated when ta0drbl is read read ta0drbl read ta0drbh read value 00h read value 00h ta0drbl ta0drbh ta0cr timer stop 18fd 0000 0001 0002 18fe 18ff 1900 1901 1902 1903 1904 1905 1906 0000 fd 00 01 00 18 02 fe ff 00 01 02 03 04 05 06 00 00 ta0mod read value feh read value 18h read value 00h read value 00h read value 18h
13.4.2 external trigger timer mode in the external trigger timer mode, the up counter starts counting when it is triggered by the input to the tca0 pin. 13.4.2.1 setting setting the operation mode selection ta0mod to "100" activates the external trigger timer mode. select the source clock at ta0mod. select the trigger edge at the trigger edge input selection ta0mod. setting ta0mod to "0" selects the rising edge, and setting it to "1" selects the falling edge. note that this mode uses the ta0 input pin, and the tca0 pin must be set to the input mode beforehand in port settings. the operation is started by setting ta0cr to "1". after the timer is started, writing to ta0mod and ta0cr is disabled. be sure to complete the required mode settings before starting the timer. 13.4.2.2 operation after the timer is started, when the selected trigger edge is input to the tca0 pin, the up counter increments according to the selected source clock. when a match between the up counter value and the value set to timer register a (ta0dra) is detected, an inttca0 interrupt request is generated and the up counter is cleared to "0x0000". after being cleared, the up counter continues counting. when ta0mod is "1" and the edge opposite to the selected trigger edge is detected, the up counter stops counting and is cleared to "0x0000". subsequently, when the selected trigger edge is detected, the up counter restarts counting. in this mode, an interrupt request can be generated by detecting that the input pulse exceeds a certain pulse width. if ta0mod is "0", the detection of the selected edge and the opposite edge is ignored during the period from the detection of the specified trigger edge and the start of counting through until the match detection. setting ta0cr to "0" during the timer operation causes the up counter to stop counting and be cleared to "0x0000". 13.4.2.3 auto capture refer to "13.4.1.3 auto capture". 13.4.2.4 register buffer configuration refer to "13.4.1.4 register buffer configuration". tmp89ch42 page 155 rb002
figure 13-4 external trigger timer timing chart tmp89ch42 13. 16-bit timer counter (tca) 13.4 timer function page 156 rb002 source clock counter timer start counting start edge is invalid during counting counting start 1 0 n m write to ta0dral write to ta0drah ta0dral match detection write n write s write m write r reflected by writing to ta0drah reflected by writing to ta0drah counter clear inttca0 interrupt request 23 mn-1 mn 01 rs 01 220 3 ta0drah ta0cr s r timer stop match detection counter clear rs-1 ta0mod tca0 pin input when the trigger is started (ta0mod=?0?) timer start counting start counting start counting start counting stop 1 0 n m ta0dral match detection write n write s write m write r reflected by writing to ta0drah reflected by writing to ta0drah counter clear counter clear inttca0 interrupt request 23 mn-1 mn 01 rs 01 1 20 0 ta0drah ta0cr s r timer stop match detection counter clear rs-1 ta0mod when the trigger is started and stopped (ta0mod=?1?) edge is invalid during counting source clock counter write to ta0dral write to ta0drah tca0 pin input
13.4.3 event counter mode in the event counter mode, the up counter counts up at the edge of the input to the tca0 pin. 13.4.3.1 setting setting the operation mode selection ta0mod to "010" activates the event counter mode. set the trigger edge at the external trigger input selection ta0mod. setting ta0mod to "0" selects the rising edge, and setting it to "1" selects the falling edge for counting up. note that this mode uses the ta0 input pin, and the tca0 pin must be set to the input mode beforehand in port settings. the operation is started by setting ta0cr to "1". after the timer is started, writing to ta0mod and ta0cr is disabled. be sure to complete the required mode settings before starting the timer. 13.4.3.2 operation after the event counter mode is started, when the selected trigger edge is input to the tca0 pin, the up counter increments. when a match between the up counter value and the value set to timer register a (ta0dra) is detected, an inttca0 interrupt request is generated and the up counter is cleared to "0x0000". after being cleared, the up counter continues counting and counts up at each edge of the input to the tca0 pin. setting ta0cr to "0" during the operation causes the up counter to stop counting and be cleared to "0x0000". the maximum frequency to be supplied is fcgck/2 [hz] (in the normal 1/2 or idle 1/2 mode) or fs/2 [hz] (in the slow 1/2 or sleep 1 mode), and a pulse width of two machine cycles or more is required at both the "h" and "l" levels. 13.4.3.3 auto capture refer to "13.4.1.3 auto capture". 13.4.3.4 register buffer configuration refer to "13.4.1.4 register buffer configuration". tmp89ch42 page 157 rb002
figure 13-5 event count mode timing chart tmp89ch42 13. 16-bit timer counter (tca) 13.4 timer function page 158 rb002 tca0 pin input counter timer start when the rising edge is selected (ta0mod=?0?) 1 0 n m write to ta0dral write to ta0drah ta0dral match detection write n write s write m write r reflected by writing to ta0drah reflected by writing to ta0drah counter clear inttca0 interrupt request 23 4 mn-1 mn 01 rs 01 220 3 ta0drah ta0cr s r timer stop match detection counter clear rs-1
13.4.4 window mode in the window mode, the up counter counts up at the rising edge of the pulse that is logical anded product of the input pulse to the tca0 pin (window pulse) and the internal clock. 13.4.4.1 setting setting the operation mode selection ta0mod to "101" activates the window mode. select the source clock at ta0mod. select the window pulse level at the trigger edge input selection ta0mod. setting ta0mod to "0" enables counting up as long as the window pulse is at the "h" level. setting ta0mod to "1" enables counting up as long as the window pulse is at the "l" level. note that this mode uses the ta0 input pin, and the tca0 pin must be set to the input mode beforehand in port settings. the operation is started by setting ta0cr to "1". after the timer is started, writing to ta0mod and ta0cr is disabled. be sure to complete the required mode settings before starting the timer. 13.4.4.2 operation after the operation is started, when the level selected at ta0mod is input to the tca0 pin, the up counter increments according to the source clock selected at ta0mod. when a match between the up counter value and the value set to timer register a (ta0dra) is detected, an inttca0 interrupt request is generated and the up counter is cleared to "0x0000". after being cleared, the up counter restarts counting. the maximum frequency to be supplied must be slow enough for the program to analyze the count value. define a frequency pulse that is sufficiently lower than the programmed internal source clock. setting ta0cr to "0" during the timer operation causes the up counter to stop counting and be cleared to "0x0000". 13.4.4.3 auto capture refer to "13.4.1.3 auto capture". 13.4.4.4 register buffer configuration refer to "13.4.1.4 register buffer configuration". tmp89ch42 page 159 rb002
figure 13-6 window mode timing chart tmp89ch42 13. 16-bit timer counter (tca) 13.4 timer function page 160 rb002 source clock counter timer start count in the period of h level count in the period of h level 1 0 n m write to ta0dral write to ta0drah ta0dral match detection write n write m reflected by writing to ta0drah counter clear inttca0 interrupt request 25 46 456 3 mn-1 mn 1 02 0 3 ta0drah ta0cr timer stop ta0mod tca0 pin input during the h-level counting (ta0mod=?0?)
13.4.5 pulse width measurement mode in the pulse width measurement mode, the up counter starts counting at the rising/falling edge(s) of the input to the tca0 pin and measures the input pulse width based on the internal clock. 13.4.5.1 setting setting the operation mode selection ta0mod to "110" activates the pulse width measurement mode. select the source clock at ta0mod. select the trigger edge at the trigger edge input selection ta0mod. setting ta0mod to "0" selects the rising edge, and setting it to "1" selects the falling edge as a trigger to start the capture. the operation after capturing is determined by the pulse width measurement mode control ta0mod. setting ta0mod to "0" selects the double-edge capture. setting ta0mod to "1" selects the single-edge capture. the operation to be executed in case of an overflow of the up counter can be selected at the overflow interrupt control ta0cr. setting ta0ove to "1" makes an inttca0 interrupt request occur in case of an overflow. setting ta0ove to "0" makes no inttca0 interrupt request occur in case of an overflow. note that this mode uses the ta0 input pin, and the tca0 pin must be set to the input mode beforehand in port settings. the operation is started by setting ta0cr to "1". in this time, ta0dra and ta0drb register are initialized to "0x0000". after the timer is started, writing to ta0mod and ta0cr is disabled. be sure to complete the required mode settings before starting the timer. 13.4.5.2 operation after the timer is started, when the selected trigger edge (start edge) is input to the tca0 pin, inttca0 interrupt request is generated, and then the up counter increments according to the selected source clock. subsequently, when the edge opposite to the selected edge is detected, the up counter value is captured into ta0drb, an inttca0 interrupt request is generated, and ta0sr is set to "1". depending on the ta0mod setting, the operation differs as follows: ? double-edge capture (when ta0mod is "0") the up counter continues counting up after the edge opposite to the selected edge is detected. subsequently, when the selected trigger edge is input, the up counter value is captured into ta0dra, an inttca0 interrupt request is generated, and ta0sr is set to "1". at this time, the up counter is cleared to "0x0000". ? single-edge capture (when ta0mod is "1") the up counter stops counting up and is cleared to "0x0000" when the edge opposite to the selected edge is detected. subsequently, when the start edge is input, inttca0 interrupt request is generated, and then the up counter restarts increment. when the up counter overflows during capturing, the overflow flag ta0sr is set to "1". at this time, an inttca0 interrupt request occurs if the overflow interrupt control ta0cr is set to "1". the capture completion flags (ta0sr and the overflow flag (ta0sr) are cleared to "0" automatically when ta0sr is read. tmp89ch42 page 161 rb002
the captured value must be read from ta0drb (and also from ta0dra for the double-edge capture) before the next trigger edge is detected. if the captured value is not read, it becomes undefined. ta0dra and ta0drb must be read by using a 16-bit access instruction. setting ta0cr to "0" during the timer operation causes the up counter to stop counting and be cleared to "0x0000". note 1: after the timer is started, if the edge opposite to the selected trigger edge is detected first, no capture is executed and no inttca0 interrupt request occurs. in this case, the capture starts when the selected trigger edge is detected next. figure 13-7 pulse width measurement mode timing chart tmp89ch42 13. 16-bit timer counter (tca) 13.4 timer function page 162 rb002 source clock counter counter clear counter clear counter clear counter clear timer start count start count start after the timer is started, if the falling edge is detected first, no interrupt occurs. 1 0 ta0drbh, l inttca0 interrupt request 0 24 3 3 mn-1 mn 1 0 mn 20 ta0cr timer stop ta0mod tca0 pin input single-edge capture (ta0mod=?1?) after the timer is started, if the falling edge is detected first, no interrupt occurs. source clock counter timer start 1 0 ta0drbh, l inttca0 interrupt request 0 24 3 mn-1 mn mn+1 st-1 st mn 0 012 0 ta0drah, l st ta0cr timer stop ta0mod tca0 pin input double-edge capture (ta0mod=?0?) ta0sr ta0sr ta0sr read ta0drb read ta0dra read ta0sr read ta0sr read ta0sr ta0sr read ta0sr read ta0sr read ta0drb read
13.4.5.3 capture process figure 13-8 shows an example of the capture process for inttca0 interrupt subroutine. the capture edge or overflow state can be easily judged by status register (ta0sr). figure 13-8 example of capture process tmp89ch42 page 163 rb002 reti ta0sr ta0sr ta0sr read error handling ta0drb read 1 overflow interrupt process for single-edge capture 0 (no overflow) 1 (capture) 0 no capture inttca0 interrupt subroutine inttca0 interrupt subroutin reti ta0sr ta0sr ta0sr read error handling ta0drb read 1 overflow interrupt process for double-edge capture 0 (no overflow) 1 (capture) 0 no capture 1 (capture) 0 no capture ta0sr ta0dra read capture value handling capture value handling
13.4.6 programmable pulse generate (ppg) mode in the ppg output mode, an arbitrary duty pulse is output by two timer registers. 13.4.6.1 setting setting the operation mode selection ta0mod to "011" activates the ppg output mode. select the source clock at ta0mod. select continuous or one-shot ppg output at ta0cr. set the ppg output cycle at ta0dra and set the time until the output is reversed first at ta0drb. be sure to set register values so that ta0dra is larger than ta0drb. note that this mode uses the ppga0 pin. the ppga0 pin must be set to the output mode beforehand in port settings. set the initial state of the ppga0 pin at the timer flip-flop ta0cr. setting ta0cr to "1" selects the "h" level as the initial state of the ppga0 pin. setting ta0cr to "0" selects the "l" level as the initial state of the ppga0 pin. the operation is started by setting ta0cr to "1". after the timer is started, writing to ta0mod and ta0cr is disabled. be sure to complete the required mode settings before starting the timer. 13.4.6.2 operation after the timer is started, the up counter increments . when a match between the up counter value and the value set to timer register b (ta0drb) is detected, the ppga0 pin is changed to the "h" level if ta0cr is "0", or the ppga0 pin is changed to the "l" level if ta0cr is "1". subsequently, the up counter continues counting. when a match between the up counter value and the value set to timer register a (ta0dra) is detected, the ppga0 pin is changed to the "l" level if ta0cr is "0", or the ppga0 pin is changed to the "h" level if ta0cr is "1". at this time, an inttca0 interrupt request occurs. if the ppg output control ta0cr is set to "1" (one-shot), ta0cr is automatically cleared to "0" and the timer stops. if ta0cr is set to "0" (continuous), the up counter is cleared to "0x0000" and continues counting and ppg output. when ta0cr is set to "0" (including the auto stop by the one-shot oper- ation) during the ppg output, the ppga0 pin returns to the level set in ta0cr. ta0cr can be changed during the operation. changing ta0cr from "1" to "0" during the operation cancels the one-shot operation and enables the continuous operation. changing ta0cr from "0" to "1" during the operation clears ta0cr to "0" and stops the timer automatically after the current pulse output is completed. timer registers a and b can be set to the double buffer. setting ta0cr to "1" enables the double buffer. when the values set to ta0dra and ta0drb are changed during the ppg output with the double buffer enabled, the writing to ta0dra and ta0drb will not immediately become effective but will become effective when a match between ta0dra and the up counter is detected. if the double buffer is disabled, the writing to ta0dra and ta0drb will become effective immediately. if the written value is smaller than the up counter value, the up counter overflows. after a cycle, the counter match process is executed to reverse the output. tmp89ch42 13. 16-bit timer counter (tca) 13.4 timer function page 164 rb002
13.4.6.3 register buffer configuration (1) temporary buffer the tmp89ch42 contains an 8-bit temporary buffer. when a write instruction is executed on ta0dral (ta0drbl), the data is first stored into this temporary buffer, whether the double buffer is enabled or disabled. subsequently, when a write instruction is executed on ta0drah (ta0drbh), the set value is stored into the double buffer or ta0drah (ta0drbh). at the same time, the set value in the temporary buffer is stored into the double buffer or ta0dral (ta0drbl). (this structure is designed to enable the set values of the lower-level register and the higher-level register simultaneously.) therefore, when setting data to ta0dra (ta0drb), be sure to write the data into ta0dral and ta0drah (ta0drbl and ta0drbh) in this order. see figure 13-1 for the temporary buffer configuration. (2) double buffer in the tmp89ch42, the double buffer can be used by setting ta0cr. setting ta0cr to "0" disables the double buffer. setting ta0cr to "1" enables the double buffer. see figure 13-1 for the double buffer configuration. - when the double buffer is enabled when a write instruction is executed on ta0drah (ta0drbh) during the timer operation, the set value is first stored into the double buffer, and ta0drah/l are not updated immedi- ately. ta0drah/l (ta0drbh/l) compare the last set values to the counter value. if a match is detected, an inttca0 interrupt request is generated and the double buffer set value is stored into ta0drah/l (ta0drbh/l). subsequently, the match detection is executed using a new set value. when a read instruction is executed on ta0drah/l (ta0drbh/l), the double buffer value (the last set value) is read, not the ta0drah/l (ta0drbh/l) values (the current effective values). when a write instruction is executed on ta0drah/l (ta0drbh/l) while the timer is stopped, the set value is immediately stored into both the double buffer and ta0drah/l (ta0drbh/l). - when the double buffer is disabled when a write instruction is executed on ta0drah (ta0drbh) during the timer operation, the set value is immediately stored in ta0drah/l (ta0drbh/l). subsequently, the match detection is executed using a new set value. if the values set to ta0drah/l (ta0drbh/l) are smaller than the up counter value, the up counter overflows and the match detection is executed using a new set value. as a result, the output pulse width may be longer than the set time. if that is a problem, enable the double buffer. when a write instruction is executed on ta0drah/l (ta0drbh/l) while the timer is stopped, the set value is immediately stored into ta0drah/l (ta0drbh/l). tmp89ch42 page 165 rb002
figure 13-9 ppg mode timing chart tmp89ch42 13. 16-bit timer counter (tca) 13.4 timer function page 166 rb002 source clock counter timer start 1 0 n m m (duty pulse) m (duty pulse) n (1 cycle) r (duty pulse) s (1 cycle) s r write to ta0dral, h write to ta0drbl, h ta0dral, h match detection match detection write n write s write m write r becomes the level set at ta0tff when the timer is stopped reflected by an interrupt request returns to the level set at ta0tff counter clear inttca interrupt request 2m 1 m+1 n 00 ta0drbl, h ta0cr timer stop match detection match detection counter clear 2r 1 r+1 r r+1 s 0 match detection ta0mod ppg0 pin output continuous (ta0cr=?0?) double buffer (ta0mod=?1?) r (duty pulse) source clock counter timer start 1 0 n m n (1 cycle) write to ta0dral, h write to ta0drbl, h ta0dral, h match detection match detection write n write m becomes the level set at ta0tff when the timer is stopped returns to the level set at ta0tff counter clear inttca interrupt request 2m m+1 n 0 ta0drbl, h ta0cr timer stops automatically ta0mod ppg0 pin output one-shot (ta0cr=?1?)
13.5 noise canceller the digital noise canceller can be used in the operation modes that use the tca0 pin. 13.5.1 setting when the digital noise canceller is used, the input level is sampled at the sampling intervals set at ta0cr. when the same level is detected three times consecutively, the level of the input to the timer is changed. setting ta0cr to any values than "00" allows the noise canceller to start operation, regardless of the ta0cr value. when the noise canceller is used, allow the timer to start after a period of time that is equal to four times the sampling interval after ta0cr is set has elapsed. this stabilizes the input signal. set ta0cr while the timer is stopped (ta0cr = "0"). when ta0cr is "1", writing is ignored. in the slow 1/2 or sleep 1 mode, setting ta0cr to "11" selects fs/2 as the source clock for the operation. setting ta0cr to "00" disables the noise canceller. setting ta0cr to "01" or "10" disables the tca0 pin input. table 13-4 noise cancel time ( fcgck = 10 [mhz] ) ta0nc sampling interval time removed as noise time regarded as signal 00 none - - 01 200 ns (2/fcgck) 600 ns or less 800 ns or more 10 400 ns (4/fcgck) 1.2 s or less 1.6 s or more 11 25.6 s (256/fcgck) 76.8 s or less 102.4 s or more tmp89ch42 page 167 rb002
13.6 revision history rev description rb000 "figure 13-1 timer counter a0" "13.4.5.2 operation" "figure 13-7 pulse width measurement mode timing chart" revised condition and timing of intta0 interrupt request generating for pulse width measurement mode. rb001 revised hex character from "h" to "0x". "13.4.5.1 setting" added ta0dra and ta0drb description (initialized register). "13.4.5.3 capture process" added new chapter. rb002 "figure 13-7 pulse width measurement mode timing chart" revised ta0mod value. revised interrupt name from "intta0" to "inttca0". revised timer input name from "ta0" to "tca0". tmp89ch42 13. 16-bit timer counter (tca) 13.6 revision history page 168 rb002
14. 8-bit timer counter (tc0) the tmp89ch42 contains 4 channels of high-performance 8-bit timer counters (tc0). each timer can be used for time measurement and pulse output with a prescribed width. two 8-bit timer counters are cascadable to form a 16-bit timer. this chapter describes 2 channels of 8-bit timer counters 00 and 01. for 8-bit timer counters 02 and 03, replace the sfr addresses and pin names as shown in table 14-1 and table 14-2. table 14-1 sfr address assignment 16-bit mode t0xreg (address) t0xpwm (address) t0xmod (address) t0xxcr (address) low power consumption register timer counter 00 lower t00reg (0x0026) t00pwm (0x0028) t00mod (0x002a) t001cr (0x002c) poffcr0 timer counter 01 higher t01reg (0x0027) t01pwm (0x0029) t01mod (0x002b) timer counter 02 lower t02reg (0x0f88) t02pwm (0x0f8a) t02mod (0x0f8c) t023cr (0x0f8e) poffcr0 timer counter 03 higher t03reg (0x0f89) t03pwm (0x0f8b) t03mod (0x0f8d) table 14-2 pin names timer input pin pwm output pin ppg output pin timer counter 00 tc00 pin pwm0 pin ppg0 pin timer counter 01 tc01 pin pwm1 pin ppg1 pin timer counter 02 tc02 pin pwm2 pin ppg2 pin timer counter 03 tc03 pin pwm3 pin ppg3 pin tmp89ch42 page 169 ra005
14.1 configuration figure 14-1 8-bit timer counters 00 and 01 tmp89ch42 14. 8-bit timer counter (tc0) 14.1 configuration page 170 ra005 t01reg selector selector selector selector reading and writing of t01reg reading and writing of t01pwm t01pwm internal bus 01 0 0 0 1 1 1 comparator comparator 8-bit up counter 8-bit up counter comparator comparator t00reg dbe1 fcgck/2 11 or fs/2 4 fcgck/2 10 or fs/2 3 fcgck/2 8 fcgck/2 6 fcgck/2 4 fcgck/2 2 fcgck/2 fcgck or fs/2 2 i a b c d e f g h y s0 s1 1 0 y s 0 1 y s 1 0 y s selector selector selector selector overflow clear count up count up clear overflow timer/event count modes 8/16-bit ppg mode reading and writing of t00reg reading and writing of t00pwm t00pwm double buffer double buffer double buffer double buffer 01 0 0 0 1 1 1 inttc01 interrupt request ppg1 pwm1 pin output tff1 internal bus t01mod t001cr 2 tck1 ein1 tff0 tcm0 dbe0 dbe1 tcm1 tff1 outand tcas tc00run tc01run t00mod tck0 ein0 2 2 2 tc00 pin input fcgck/2 11 or fs/2 4 fcgck/2 10 or fs/2 3 fcgck/2 8 fcgck/2 6 fcgck/2 4 fcgck/2 2 fcgck/2 fcgck or fs/2 2 i a b c d e f g h y s0 s1 tc01 pin input 8-bit pwm mode counter f/f 12-bit pwm mode 8-bit pwm mode counter 12-bit pwm mode timer/event count modes 8-bit ppg mode tcas tcas tcas inttc00 interrupt request 16-bit ppg mode ppg0 pwm0 pin output f/f 1 0 y s outand tff0
14.2 control 14.2.1 timer counter 00 the timer counter 00 is controlled by the timer counter 00 mode register (t00mod) and two 8-bit timer registers (t00reg and t00pwm). timer register 00 t00reg 15 14 13 12 11 10 9 8 (0x0026) bit symbol t00reg read/write r/w after reset 1 1 1 1 1 1 1 1 timer register 00 t00pwm 7 6 5 4 3 2 1 0 (0x0028) bit symbol t00pwm read/write r/w after reset 1 1 1 1 1 1 1 1 note 1: for the configuration of t00pwm in the 8-bit and 12-bit pwm modes, refer to "14.4.3 8-bit pulse width modulation (pwm) output mode" and "14.4.7 12-bit pulse width modulation (pwm) output mode". tmp89ch42 page 171 ra005
timer counter 00 mode register t00mod 7 6 5 4 3 2 1 0 (0x002a) bit symbol tff0 dbe0 tck0 ein0 tcm0 read/write r/w r/w r/w r/w r/w after reset 1 1 0 0 0 0 0 0 tff0 timer f/f0 control 0 1 clear set dbe0 double buffer control 0 1 disable the double buffer enable the double buffer tck0 operation clock selection normal1/2 or idle1/2 mode slow1/2 or sleep1 mode syscr1 = "0" syscr1 = "1" 000 fcgck/2 11 fs/2 4 fs/2 4 001 fcgck/2 10 fs/2 3 fs/2 3 010 fcgck/2 8 fcgck/2 8 - 011 fcgck/2 6 fcgck/2 6 - 100 fcgck/2 4 fcgck/2 4 - 101 fcgck/2 2 fcgck/2 2 - 110 fcgck/2 fcgck/2 - 111 fcgck fcgck fs/2 2 ein0 selection for using external source clock 0 1 select the internal clock as the source clock. select an external clock as the source clock. (the falling edge of the tc00 pin) tcm0 operation mode selection 00 8-bit timer/event counter modes 01 8-bit timer/event counter modes 10 8-bit pulse width modulation output (pwm) mode 11 8-bit programmable pulse generate (ppg) mode note 1: fcgck: gear clock [hz], fs: low-frequency clock [hz] note 2: set t00mod while the timer is stopped. writing data into t00mod is invalid during the timer operation. note 3: in the 8-bit timer/event modes, the tff0 setting is invalid. in this mode, when the pwm0 and ppg0 pins are set as the function output pins in the port setting, the pins always output the "h" level. note 4: when ein0 is set to "1" and the external clock input is selected as the source clock, the tck0 setting is ignored. note 5: when the t001cr bit is "1", timer 00 operates in the 16-bit mode. the t00mod setting is invalid and timer 00 cannot be used independently in this mode. when the pwm0 and ppg0 pins are set to the function output pins in the port setting, the pins always output the "h" level. note 6: when the 16-bit mode is selected at t001cr, the timer start is controlled at t001cr. timer 00 is not started by writing data into t001cr. tmp89ch42 14. 8-bit timer counter (tc0) 14.2 control page 172 ra005
14.2.2 timer counter 01 timer counter 01 is controlled by timer counter 01 mode register (t01mod) and two 8-bit timer registers (t01reg and t01pwm). timer register 01 t01reg 15 14 13 12 11 10 9 8 (0x0027) bit symbol t01reg read/write r/w after reset 1 1 1 1 1 1 1 1 timer register 01 t01pwm 7 6 5 4 3 2 1 0 (0x0029) bit symbol t01pwm read/write r/w after reset 1 1 1 1 1 1 1 1 note 1: for the configuration of t00pwm in the 8-bit and 12-bit pwm modes, refer to "14.4.3 8-bit pulse width modulation (pwm) output mode" and "14.4.7 12-bit pulse width modulation (pwm) output mode". tmp89ch42 page 173 ra005
timer counter 01 mode register t01mod 7 6 5 4 3 2 1 0 (0x002b) bit symbol tff1 dbe1 tck1 ein1 tcm1 read/write r/w r/w r/w r/w r/w after reset 1 1 0 0 0 0 0 0 tff1 timer f/f1 control 0 1 clear set dbe1 double buffer control 0 1 disable the double buffer enable the double buffer tck1 operation clock selection normal1/2 or idle1/2 mode slow1/2 or sleep1 mode syscr1 = "0" syscr1 = "1" 000 fcgck/2 11 fs/2 4 fs/2 4 001 fcgck/2 10 fs/2 3 fs/2 3 010 fcgck/2 8 fcgck/2 8 - 011 fcgck/2 6 fcgck/2 6 - 100 fcgck/2 4 fcgck/2 4 - 101 fcgck/2 2 fcgck/2 2 - 110 fcgck/2 fcgck/2 - 111 fcgck fcgck fs/2 2 ein1 selection for using external source clock 0 1 select the internal clock as the source clock. select an external clock as the source clock. (the falling edge of the tc01 pin) tcm1 operation mode selection t001cr="0" (8-bit mode) t001cr="1" (16-bit mode) 00 8-bit timer/event counter modes 16-bit timer/event counter modes 01 8-bit timer/event counter modes 16-bit timer/event counter modes 10 8-bit pulse width modulation output (pwm) mode 12-bit pulse width modulation out- put (pwm) mode 11 8-bit programmable pulse gener- ate (ppg) mode 16-bit programmable pulse gener- ate (ppg) mode note 1: fcgck: gear clock [hz], fs: low-frequency clock [hz] note 2: set t01mod while the timer is stopped. writing data into t01mod is invalid during the timer operation. note 3: in the 8-bit timer/event modes, the tff1 setting is invalid. in this mode, when the pwm1 and ppg1 pins are set as the function output pins in the port setting, the pins always output the "h" level. note 4: when ein1 is set to "1" and the external clock input is selected as the source clock, the tck1 setting is ignored. tmp89ch42 14. 8-bit timer counter (tc0) 14.2 control page 174 ra005
14.2.3 common to timer counters 00 and 01 timer counters 00 and 01 have the low power consumption register (poffcr0) and timer 00 and 01 control registers in common. low power consumption register 0 poffcr0 7 6 5 4 3 2 1 0 (0x0f74) bit symbol - - tc023en tc001en - - tca1en tca0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 tc023en tc02,03 control 0 1 disable enable tc001en tc00,01 control 0 1 disable enable tca1en tca1 control 0 1 disable enable tca0en tca0 control 0 1 disable enable tmp89ch42 page 175 ra005
timer counter 01 control register t001cr 7 6 5 4 3 2 1 0 (0x002c) bit symbol - - - - outand tcas t01run t00run read/write r r r r r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 outand timers 00 and 01 output control 0 output the timer 00 output from the pwm0 and ppg0 pins and the timer 01 output from the pwm1 and ppg1 pins. 1 output a pulse that is a logical anded product of the outputs of timers 00 and 01 from the pwm1 and ppg1 pins. tcas timers 00 and 01 cascade control 0 1 use timers 00 and 01 independently (8-bit mode). cascade timers 00 and 01 (16-bit mode). t01run timer 01 control timers 00/01 control (16-bit mode) 0 1 stop and clear the counter start t00run timer 00 control 0 1 stop and clear the counter start note 1: when stop mode is started, t00run and t01run are cleared to "0" and the timers stop. set t001cr again to use timers 00 and 01 after stop mode is released. note 2: when a read instruction is executed on t001cr, bits 7 to 4 are read as "0". note 3: when outand is "1", output is obtained from the pwm1 and ppg1 pins only. there is no timer output to the pwm0 and ppg0 pins. if the pwm0 and ppg0 pins are set as the function output pins in the port setting, the pins always output "h". note 4: outand and tcas can be changed only when both tc01run and tc00run are "0". when either tc01run or tc00run is "1" or both are "1", the register values remain unchanged by executing write instructions on outand and tcas. outand and tcas can be changed at the same time as tc01run and tc00run are changed from "0" to "1". tmp89ch42 14. 8-bit timer counter (tc0) 14.2 control page 176 ra005
14.2.4 operation modes and usable source clocks the operations modes of the 8-bit timers and the usable source clocks are listed below. table 14-3 operation modes and usable source clocks (normal1/2 and idle1/2 modes) tck0 000 001 010 011 100 101 110 111 tc0i pin input operation mode fcgck/2 11 or fs/2 4 fcgck/2 10 or fs/2 3 fcgck/2 8 fcgck/2 6 fcgck/2 4 fcgck/2 2 fcgck/2 fcgck 8-bit timer modes 8-bit timer - 8-bit event counter - - - - - - - - 8-bit pwm - 8-bit ppg - 16-bit timer modes 16-bit timer - 16-bit event counter - - - - - - - - 12-bit pwm 16-bit ppg note 1: : usable, -: unusable note 2: set the source clock in the 16-bit modes on the tc01 side (tck1). note 3: when the low-frequency clock, fs, is not oscillating, it must not be selected as the source clock. if fs is selected when it is not oscillating, no source clock is supplied to the timer, and the timer remains stopped. note 4: i=0, 1 (i=0 only in the 16-bit modes) note 5: the operation modes of the 8-bit timers and the usable source clocks are listed below. table 14-4 operation modes and usable source clocks (slow1/2 and sleep1 modes) tck0 000 001 010 011 100 101 110 111 tc0i pin input operation mode fs/2 4 fs/2 3 - - - - - fs/2 2 8-bit timer modes 8-bit timer - - - - - - 8-bit event counter - - - - - - - - 8-bit pwm - - - - - - 8-bit ppg - - - - - - 16-bit timer modes 16-bit timer - - - - - - 16-bit event counter - - - - - - - - 12-bit pwm - - - - - 16-bit ppg - - - - - note 1: : usable, -: unusable note 2: set the source clock in the 16-bit modes on the tc01 side (tck1). note 3: i=0, 1 (i=0 only in the 16-bit modes) tmp89ch42 page 177 ra005
14.3 low power consumption function timer counters 00 and 01 have the low power consumption registers (poffcr 0 ) that save power when the timers are not used. setting poffcr0 to "0" disables the basic clock supply to timer counters 00 and 01 to save power. note that this renders the timers unusable. setting poffcr 0 to "1" enables the basic clock supply to timer counters 00 and 01 and allows the timers to operate. after reset, poffcr 0 are initialized to "0", and this makes the timers unusable. when using the timers for the first time, be sure to set poffcr 0 to "1" in the initial setting of the program (before the timer control registers are operated). do not change poffcr0 to "0" during the timer operation. otherwise timer counters 00 and 01 may operate unexpectedly. tmp89ch42 14. 8-bit timer counter (tc0) 14.3 low power consumption function page 178 ra005
14.4 functions timer counters tc00 and tc01 have 8-bit modes in which they are used independently and 16-bit modes in which they are cascaded. the 8-bit modes include four operation modes; the 8-bit timer mode, the 8-bit event counter mode, the 8-bit pulse width modulation output (pwm) mode and the 8-bit programmable pulse generated output (ppg) mode. the 16-bit modes include four operation modes; the 16-bit timer mode, the 16-bit event counter mode, the 12-bit pwm mode and the 16-bit ppg mode. 14.4.1 8-bit timer mode in the 8-bit timer mode, the up-counter counts up using the internal clock, and interrupts can be generated regularly at specified times. the operation of tc00 is described below, and the same applies to the operation of tc01. (replace tc00- by tc01-). 14.4.1.1 setting tc00 is put into the 8-bit timer mode by setting t00mod to "00" or "01", t001cr to "0" and t00mod to "0". select the source clock at t00mod. set the count value to be used for the match detection as an 8-bit value at the timer register t00reg. set t00mod to "1" to use the double buffer. setting t001cr to "1" starts the operation. after the timer is started, writing to t00mod becomes invalid. be sure to complete the required mode settings before starting the timer. 14.4.1.2 operation setting t001cr to "1" allows the 8-bit up counter to increment based on the selected internal source clock. when a match between the up counter value and the t00reg set value is detected, an inttc00 interrupt request is generated and the up counter is cleared to "0x00". after being cleared, the up counter restarts counting. setting t001cr to "0" during the timer operation makes the up counter stop counting and be cleared to "0x00". 14.4.1.3 double buffer the double buffer can be used for t00reg by setting t00mod. the double buffer is disabled by setting t00mod to "0" or enabled by setting t00mod to "1". ? when the double buffer is enabled when a write instruction is executed on t00reg during the timer operation, the set value is initially stored in the double buffer, and t00reg is not immediately updated. t00reg compares the previous set value with the up counter value. when the values match, an inttc00 interrupt request is generated and the double buffer set value is stored in t00reg. subsequently, the match detection is executed using a new set value. when a write instruction is executed on t00reg while the timer is stopped, the set value is immediately stored in both the double buffer and t00reg. ? when the double buffer is disabled when a write instruction is executed on t00reg during the timer operation, the set value is immediately stored in t00reg. subsequently, the match detection is executed using a new set value. if the value set to t00reg is smaller than the up counter value, the match detection is executed using a new set value after the up counter overflows. therefore, the interrupt request interval may tmp89ch42 page 179 ra005
be longer than the selected time. if the value set to t00reg is equal to the up counter value, the match detection is executed immediately after data is written into t00reg. therefore, the interrupt request interval may not be an integral multiple of the source clock (figure 14-3). if these are problems, enable the double buffer. when a write instruction is executed on t00reg while the timer is stopped, the set value is immediately stored in t00reg. when a read instruction is executed on t00reg, the last value written into t00reg is read out, regardless of the t00mod setting. table 14-5 8-bit timer mode resolution and maximum time setting t00mod source clock [hz] resolution maximum time setting normal1/2 or idle1/2 mode slow1/2 or sleep1 mode fcgck=10mhz fs=32.768khz fcgck=10mhz fs=32.768khz syscr1 = "0" syscr1 = "1" 000 fcgck/2 11 fs/2 4 fs/2 4 204.8s 488.2s 52.2ms 124.5ms 001 fcgck/2 10 fs/2 3 fs/2 3 102.4s 244.1s 26.1ms 62.3ms 010 fcgck/2 8 fcgck/2 8 - 25.6s - 6.5ms - 011 fcgck/2 6 fcgck/2 6 - 6.4s - 1.6ms - 100 fcgck/2 4 fcgck/2 4 - 1.6s - 408s - 101 fcgck/2 2 fcgck/2 2 - 400ns - 102s - 110 fcgck/2 fcgck/2 - 200ns - 51s - 111 fcgck fcgck fs/2 2 100ns 122.1s 25.5s 31.1ms (example) operate tc00 in the 8-bit timer mode with the operation clock of fcgck/2 2 [hz] and generate interrupts at 64 s intervals (fcgck = 10 mhz) ld (poffcr0),0x10 ; sets tc001en to "1" di ; sets the interrupt master enable flag to "disable" set (eirh).4 ; sets the inttc00 interrupt enable register to "1" ei ; sets the interrupt master enable flag to "enable" ld (t00mod),0xe8 ; selects the 8-bit timer mode and fcgck/2 2 ld (t00reg),0xa0 ; sets the timer register (64s / (2 2 /fcgck) = 0xa0) set (t001cr).0 ; starts tc00 tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 180 ra005
figure 14-2 timer mode timing chart figure 14-3 operation when t00reg and the up counter have the same value tmp89ch42 page 181 ra005 source clock counter n-4 n-5 n-2 n write to t00reg write n-2 inttc00 interrupt request n-3 n-2 0 1 2 t00reg match detection counter clear t00mod source clock counter timer start 1 0 m write to t00reg match detection write m write n reflected by writing to t00reg reflected by writing to t00reg reflected by an interrupt reflected at the same time as data is written into t00reg while the timer is stopped counter clear inttc00 interrupt request 234 m-1 m 01 n 01 220 3 t00reg t001cr n timer stop match detection counter clear n-1 t00mod when the double buffer is disabled (t00mod=?0?) source clock counter timer start 1 0 m write to t00reg match detection write m write n counter clear inttc00 interrupt request 234 m-1 m 01 m 01 23 t00reg t001cr n m double buffer n match detection match detection counter clear 01 m-1 n n-1 t00mod when the double buffer is enabled (t00mod=?1?)
14.4.2 8-bit event counter mode in the 8-bit event counter mode, the up counter counts up at the falling edge of the input to the tc00 or tc01 pin. the operation of tc00 is described below, and the same applies to the operation of tc01. 14.4.2.1 setting tc00 is put into the 8-bit event counter mode by setting t00mod to "00", t001cr to "0" and t00mod to "1". set the count value to be used for the match detection as an 8-bit value at the timer register t00reg. set t00mod to "1" to use the double buffer. setting t001cr to "1" starts the operation. after the timer is started, writing to t00mod becomes invalid. be sure to complete the required mode settings before starting the timer. 14.4.2.2 operation setting t001cr to "1" allows the 8-bit up counter to increment at the falling edge of the tc00 pin. when a match between the up-counter value and the t00reg set value is detected, an inttc00 interrupt request is generated and the up counter is cleared to "0x00". after being cleared, the up counter restarts counting. setting t001cr to "0" during the timer operation makes the up counter stop counting and be cleared to "0x00". the maximum frequency to be supplied is fcgck/2 2 [hz] (in normal1/2 or idle1/2 mode) or fs/24 [hz] (in slow1/2 or sleep1 mode), and a pulse width of two machine cycles or more is required at both the "h" and "l" levels. 14.4.2.3 double buffer refer to "14.4.1.3 double buffer". (example) operate tc00 in the 8-bit event counter mode and generate an interrupt each time 16 falling edges are detected at the tc00 pin. ld (poffcr0),0x10 ; sets tc001en to "1" di ; sets the interrupt master enable flag to "disable" set (eirh).4 ; sets the inttc00 interrupt enable register to "1" ei ; sets the interrupt master enable flag to "enable" ld (t00mod),0xc4 ; selects to the 8-bit event counter mode ld (t00reg),0x10 ; sets the timer register set (t001cr).0 ; starts tc00 tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 182 ra005
figure 14-4 event counter mode timing chart tmp89ch42 page 183 ra005 tc00 pin input counter timer start when the double buffer is disabled (t00mod=?0?) 1 0 m write to t00reg match detection write m write n reflected by writing to t00reg reflected by writing to t00reg counter clear inttc00 interrupt request 23 4 m-1 m 01 n 01 220 3 t00reg t001cr n timer stop match detection counter clear n-1
14.4.3 8-bit pulse width modulation (pwm) output mode the pulse-width modulated pulses with a resolution of 7 bits are output in the 8-bit pwm mode. an additional pulse can be added to the 2 n-th duty pulse. this enables pwm output with a resolution nearly equivalent to 8 bits. (n=1, 2, 3...) the operation of tc00 is described below, and the same applies to the operation of tc01. 14.4.3.1 setting tc00 is put into the 8-bit pwm mode by setting t00mod to "10" and t001cr to "0". set t00mod to "0" and select the clock at t00mod. set the count value to be used for the match detection and the additional pulse value at the pwm register t00pwm. set t00mod to "1" to use the double buffer. setting t001cr to "1" starts the operation. after the timer is started, writing to t00mod becomes invalid. be sure to complete the required mode settings before starting the timer. in the 8-bit pwm mode, the t00pwm register is configured as follows: timer register 00 t00pwm 7 6 5 4 3 2 1 0 (0x0028) bit symbol pwmduty pwmad read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 1 1 1 1 1 1 1 1 timer register 01 t01pwm 7 6 5 4 3 2 1 0 (0x0029) bit symbol pwmduty pwmad read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 1 1 1 1 1 1 1 1 pwmduty is a 7-bit register used to set the duty pulse width value (the time before the first output change) in a cycle (128 counts of the source clock). pwmad is a register used to set the additional pulse. when pwmad is "1", an additional pulse that corresponds to 1 count of the source clock is added to the 2 n-th duty pulse (n=1, 2, 3...). in other words, the 2 n-th duty pulse has the output of pwmduty+1. the additional pulse is not added when pwmad is "0". tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 184 ra005
figure 14-5 pwm0 pulse output set the initial state of the pwm0 pin at t00mod. setting t00mod to "0" selects the "l" level as the initial state of the pwm0 pin. setting t00mod to "1" selects the "h" level as the initial state of the pwm0 pin. if the pwm0 pin is set as the function output pin in the port setting while the timer is stopped, the value of t00mod is output to the pwm0 pin. table 14-6 shows the list of output levels of the pwm0 pin. table 14-6 list of output levels of pwm0 pin tff0 pwm0 pin output level before the start of operation (initial state) t00pwm matched ( after the addition- al pulse) overflow operation stop- ped (initial state) 0 l h l l 1 h l h h and by setting "1" to t001cr bit, a logical product (and) pulse of tc00 and tc01s output can be output to pwm0 pin. by using this function, the remote-control waveform can be created eaily. 14.4.3.2 operations setting t001cr to "1" allows the up counter to increment based on the selected source clock. when a match between the lower 7 bits of the up counter value and the value set to t00pwm is detected, the output of the pwm0 pin is reversed. when t00mod is "0", the pwm0 pin changes from the "l" to "h" level. when t00mod is "1", the pwm0 pin changes from the "h" to "l" level. if t00pwm is "1", an additional pulse that corresponds to 1 count of the source clock is added at the 2 n-th match detection (n=1, 2, 3...). in other words, the pwm0 pin output is reversed at the timing of t00pwm+1. when t00mod is "0", the period of the "l" level becomes longer than the value set to t00 by 1 source clock. when t00mod is "1", the period of the "h" level becomes longer than the value set to t00pwm by 1 source clock. this function allows two cycles of output pulses to be handled with a resolution nearly equivalent to 8 bits. no additional pulse is inserted when t00pwm is "0". subsequently, the up counter continues counting up. when the up counter value reaches 128, an overflow occurs and the up counter is cleared to "0x00". at the same time, the output of the pwm0 pin is reversed. when t00mod is "0", the pwm0 pin changes from the "h" to "l" level. when t00mod tmp89ch42 page 185 ra005 t00pwm timer start additional pulse (duty pulse width) 128 counts (cycle width) 128 counts (cycle width) cycle 1 cycle 2 cycle 3 cycle 4 cycle 5 cycle 6 pwm0 pin output (tff0=?1?) t00pwm (duty pulse width) additional pulse additional pulse pwm0 pin output (tff0=?0?) inttc00 interrupt request
is "1", the pwm0 pin changes from the "l" to "h" level. if the 2 n-th overflow occurs at this time, an inttc00 interrupt request is generated. (no interrupt request is generated at the 2 n-th -1 overflow.) subsequently, the up counter continues counting up. when t001cr is set to "0" during the timer operation, the up counter is stopped and cleared to "0x00". the pwm0 pin returns to the level selected at t00mod. (example) operate tc00 in the 8-bit pwm mode with the operation clock of fcgck/2 and output a duty pulse nearly equivalent to 11.6 s (fcgck = 10 mhz) (actually, output a total duty pulse of 23.2 s in 2 cycles (51.2 s)) set (p7fc).0 ; sets p7fc0 to "1" set (p7cr).0 ; sets p7cr0 to "1" ld (poffcr0),0x10 ; sets tc001en to "1" di ; sets the interrupt master enable flag to "disable" set (eirh).4 ; sets the inttc00 interrupt enable register to "1" ei ; sets the interrupt master enable flag to "enable" ld (t00mod),0xf2 ; selects the 8-bit pwm mode and fcgck/2 ld (t00pwm),0x74 ; sets the timer register (duty pulse) ; (11.6s 2) / (2/fcgck) = 0x74 set (t001cr).0 ; starts tc00 figure 14-6 8-bit pwm mode timing chart tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 186 ra005 source clock counter timer start 1 0 m m m (duty pulse) 128 counts (cycle 1) 128 counts (cycle 2) 128 counts (cycle 3) 128 counts (cycle 4) rs rs write to t00pwm double buffer write m write r write s becomes the level selected at tff0 while the timer is stopped reflected by an interrupt request interrupt request reflected by an interrupt request returns to the level selected at tff0 inttc00 interrupt request 1 m+1 m0 t00pwm t00pwm t001cr no interrupt request is generated no interrupt request is generated 128 timer stop match detection m+1 m 1 0 128 r+1 r 1 0 128 r+1 r 1 00 128 match detection match detection counter clear overflow overflow overflow counter clear counter clear counter clear t00mod pwm0 pin output when the double buffer is enabled (t00mod=?1?) m (duty pulse) r (duty pulse) r+1 (duty pulse) additional pulse match detection
14.4.3.3 double buffer the double buffer can be used for t00pwm by setting t00mod. the double buffer is disabled by setting t00mod to "0" or enabled by setting t00mod to "1". ? when the double buffer is enabled when a write instruction is executed on t00pwm during the timer operation, the set value is first stored in the double buffer, and t00pwm is not updated immediately. t00pwm compares the previous set value with the up counter value. when the 2 n-th overflow occurs, an inttc00 interrupt request is generated and the double buffer set value is stored in t00pwm. subsequently, the match detection is executed using a new set value. when a read instruction is executed on t00pwm, the value in the double buffer (the last set value) is read out, not the t00pwm value (the currently effective value). when a write instruction is executed on t00pwm while the timer is stopped, the set value is immediately stored in both the double buffer and t00pwm. ? when the double buffer is disabled when a write instruction is executed on t00pwm during the timer operation, the set value is immediately stored in t00pwm. subsequently, the match detection is executed using a new set value. if the value set to t00pwm is smaller than the up counter value, the pwm0 pin is not reversed until the up counter overflows and a match detection is executed using a new set value. if the value set to t00pwm is equal to the up counter value, the match detection is executed immediately after data is written into t00pwm. therefore, the timing of changing the pwm0 pin may not be an integral multiple of the source clock (figure 14-7). similarly, if t00pwm is set during the additional pulse output, the timing of changing the pwm0 pin may not be an integral multiple of the source clock. if these are problems, enable the double buffer. when a write instruction is executed on t00pwm while the timer is stopped, the set value is immediately stored in t00pwm. figure 14-7 operation when t00pwm and the up counter have the same value tmp89ch42 page 187 ra005 source clock counter n-4 n-5 n-2 n write to t00pwm write n-2 pwm0 pin output n-3 n-2 n-1 n t00pwm match detection t00mod
table 14-7 resolutions and cycles in the 8-bit pwm mode t00mod source clock [hz] resolution 7-bit cycle (period 2) normal1/2 or idle1/2 mode slow1/2 or sleep1 mode fcgck=10mhz fs=32.768khz fcgck=10mhz fs=32.768khz syscr1 = "0" syscr1 = "1" 000 fcgck/2 11 fs/2 4 fs/2 4 204.8s 488.2s 26.2ms (52.4ms) 62.5ms (125ms) 001 fcgck/2 10 fs/2 3 fs/2 3 102.4s 244.1s 13.1ms (26.2ms) 31.3ms (62.5ms) 010 fcgck/2 8 fcgck/2 8 - 25.6s - 3.3ms (6.6ms) - 011 fcgck/2 6 fcgck/2 6 - 6.4s - 819.2s (1638.4s) - 100 fcgck/2 4 fcgck/2 4 - 1.6s - 204.8s (409.6s) - 101 fcgck/2 2 fcgck/2 2 - 400ns - 51.2s (102.4s) - 110 fcgck/2 fcgck/2 - 200ns - 25.6s (51.2s) - 111 fcgck fcgck fs/2 2 100ns 122.1s 12.8s (25.6s) 15.6ms (31.3ms) tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 188 ra005
14.4.4 8-bit programmable pulse generate (ppg) output mode in the 8-bit ppg mode, the pulses with arbitrary duty and cycle are output by using the t00reg and t00pwm registers. by setting the t001cr register, a pulse that is a logical anded product of the tc00 and tc01 outputs can be output to the tc01 pin. this function facilitates the generation of remote-controlled waveforms, for example. the operation of tc00 is described below, and the same applies to the operation of tc01. 14.4.4.1 setting tc00 is put into the 8-bit ppg mode by setting t00mod to "10" and t001cr to "0". set t00mod to "0" and select the clock at t00mod. set the duty pulse width at t00pwm and the cycle width at t00reg. set t00mod to "1" to use the double buffer. setting t001cr to "1" starts the operation. after the timer is started, writing to t00mod becomes invalid. be sure to complete the required mode settings before starting the timer. figure 14-8 ppg0 pulse output set the initial state of the ppg0 pin at t00mod. setting t00mod to "0" selects the "l" level as the initial state of the ppg0 pin. setting t00mod to "1" selects the "h" level as the initial state of the ppg0 pin. if the ppg0 pin is set as the function output pin in the port setting while the timer is stopped, the value of t00mod is output to the ppg0 pin. table 14-8 shows the list of output levels of the ppg0 pin. table 14-8 list of output levels of ppg0 pin tff0 ppg0 pin output level before the start of operation (initial state) t00pwm matched t00reg matched operation stop- ped (initial state) 0 l h l l 1 h l h h setting the t001cr bit to "1" allows the ppg0 pin to output a pulse that is a logical anded product of the tc00 and tc01 outputs. tmp89ch42 page 189 ra005 t00pwm timer start (duty pulse) (duty pulse) (1 cycle) (1 cycle) t00reg ppg0 pin output (tff0=?0?) ppg0 pin output (tff0=?1?) timer stop t00pwm t00reg
14.4.4.2 operation setting t001cr to "1" allows the up counter to increment based on the selected source clock. when a match between the internal up counter value and the value set to t00pwm is detected, the output of the ppg0 pin is reversed. when t00mod is "0", the ppg0 pin changes from the "l" to "h" level. when t00mod is "1", the ppg0 pin changes from the "h" to "l" level. subsequently, the up counter continues counting up. when a match between the up counter value and t00reg is detected, the output of the ppg0 pin is reversed again. when t00mod is "0", the ppg0 pin changes from the "h" to "l" level. when t00mod is "1", the ppg0 pin changes from the "l" to "h" level. at this time, an inttc00 interrupt request is generated. when t001cr is set to "0" during the operation, the up counter is stopped and cleared to "0x00". the ppg0 pin returns to the level selected at t00mod. 14.4.4.3 double buffer the double buffer can be used for t00pwm and t00reg by setting t00mod. the double buffer is disabled by setting t00mod to "0" or enabled by setting t00mod to "1". ? when the double buffer is enabled when a write instruction is executed on t00pwm (t00reg) during the timer operation, the set value is first stored in the double buffer, and t00pwm (t00reg) is not updated immediately. t00pwm (t00reg) compares the previous set value with the up counter value. when an inttc00 interrupt request is generated, the double buffer set value is stored in t00pwm (t00reg). subsequently, the match detection is executed using a new set value. when a read instruction is executed on t00pwm (t00reg), the value in the double buffer (the last set value) is read out, not the t00pwm (t00reg) value (the currently effective value). when a write instruction is executed on t00pwm (t00reg) while the timer is stopped, the set value is immediately stored in both the double buffer and t00pwm (t00reg). ? when the double buffer is disabled when a write instruction is executed on t00pwm (t00reg) during the timer operation, the set value is immediately stored in t00pwm (t00reg). subsequently, the match detection is executed using a new set value. if the value set to t00pwm (t00reg) is smaller than the up counter value, the ppg0 pin is not reversed until the up counter overflows and a match detection is executed using a new set value. if the value set to t00pwm (t00reg) is equal to the up counter value, the match detection is executed immediately after data is written into t00pwm (t00reg). therefore, the timing of changing the ppg0 pin may not be an integral multiple of the source clock (figure 14-10). if these are problems, enable the double buffer. when a write instruction is executed on t00pwm (t00reg) while the timer is stopped, the set value is immediately stored in t00pwm (t00reg). tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 190 ra005
(example) operate tc00 in the 8-bit ppg mode with the operation clock of fcgck/2 and output the 8s duty pulse in 32s cycles (fcgck = 10 mhz) set (p7fc).0 ; sets p7fc0 to "1" set (p7cr).0 ; sets p7cr0 to "1" ld (poffcr0),0x10 ; sets tc001en to "1" di ; sets the interrupt master enable flag to "disable" set (eirh).4 ; sets the inttc00 interrupt enable register to "1" ei ; sets the interrupt master enable flag to "enable" ld (t00mod),0xf3 ; selects the 8-bit ppg mode and fcgck/2 ld (t00reg),0xa0 ; sets the timer register (cycle) ; 32s / (2/fcgck) = 0xa0 ld (t00pwm),0x28 ; sets the timer register (duty pulse) ; 8s / (2/fcgck) = 0x28 set (t001cr).0 ; starts tc00 figure 14-9 8-bit ppg mode timing chart tmp89ch42 page 191 ra005 source clock counter timer start 1 0 m m m (duty pulse) p (1 cycle) s (1 cycle) s (1 cycle) w (1 cycle) rt rs write to t00pwm double buffer match detection write m write r write t becomes the level selected at tff0 while the timer is stopped returns to the level selected at tff0 inttc00 interrupt request 1 m+1 m0 t00pwm t001cr ps w write to t00reg double buffer write p write s write w p timer stop match detection r+1 r 1 0 s r+1 r 1 0 s t+1 t 1 00 w match detection match detection counter clear counter clear counter clear counter clear t00mod ppg0 pin output when the double buffer is enabled (t00mod=?1?) r (duty pulse) r (duty pulse) t (duty pulse) ps w t00reg match detection match detection match detection
figure 14-10 operation when t00pwm (t00reg) and the up counter have the same value tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 192 ra005 source clock counter n-4 n-5 n-2 n write to t00pwm (t00reg) write n-2 ppg0 pin output n-3 n-2 n-1 n t00pwm (t00reg) match detection t00mod
14.4.5 16-bit timer mode in the 16-bit timer mode, tc00 and tc01 are cascaded to form a 16-bit timer counter, which can measure a longer period than an 8-bit timer. 14.4.5.1 setting setting t001cr to "1" connects tc00 and tc01 and activates the 16-bit mode. all the settings of tc00 are ignored and those of tc01 are effective in the 16-bit mode. the 16-bit timer mode is activated by setting t01mod to "00" or "01" and t01mod to "0". select the source clock at t01mod. set the count value to be used for the match detection as a 16-bit value at the timer registers t00reg and t01reg. set the lower 8 bits of the 16-bit value at t00reg and the higher 8 bits at t01reg. (hereinafter, the 16-bit value specified by the combined setting of t01reg and t00reg is indicated as t01+00reg.) the timer register settings are reflected on the double buffer or t01+00reg when a write instruction is executed on t01reg. be sure to execute the write instructions on t00reg and t01reg in this order. (when data is written to the high-order register, the set values of the low-order and high-order registers become effective at the same time.) set t01mod to "1" to use the double buffer. setting t001cr to "1" starts the operation. after the timer is started, writing to t01mod becomes invalid. be sure to complete the required mode settings before starting the timer. (make settings when t001cr and are "0".) 14.4.5.2 operations setting t001cr to "1" allows the 16-bit up counter to increment based on the selected internal source clock. when a match between the up counter value and the t00+01reg set value is detected, an inttc01 interrupt request is generated and the up counter is cleared to "0x0000". after being cleared, the up counter restarts counting. setting t001cr to "0" during the timer operation makes the up counter stop counting and be cleared to "0x0000". 14.4.5.3 double buffer the double buffer can be used for t01+00reg by setting t01mod. the double buffer is disabled by setting t01mod to "0" or enabled by setting t01mod to "1". ? when the double buffer is enabled when write instructions are executed on t00reg and t01reg in this order during the timer operation, the set value is first stored in the double buffer, and t01+00reg is not updated im- mediately. t01+00reg compares the previous set value with the up counter value. when the values are matched, an inttc01 interrupt request is generated and the double buffer set value is stored in t01+00reg. subsequently, the match detection is executed using a new set value. when write instructions are executed on t00reg and t01reg in this order while the timer is stopped, the set value is immediately stored in both the double buffer and t01+00reg. ? when the double buffer is disabled when write instructions are executed on t00reg and t01reg in this order during the timer operation, the set value is immediately stored in t01+00reg. subsequently, the match detection is executed using a new set value. if the value set to t01+00reg is smaller than the up counter value, the match detection is executed using a new set value after the up counter overflows. therefore, the interrupt request tmp89ch42 page 193 ra005
interval may be longer than the selected time. if the value set to t01+00reg is equal to the up counter value, the match detection is executed immediately after data is written into t01+00reg. therefore, the interrupt request interval may not be an integral multiple of the source clock. if these are problems, enable the double buffer. when write instructions are executed on t00reg and t01reg in this order while the timer is stopped, the set value is immediately stored in t01+00reg. when a read instruction is executed on t01+00reg, the last value written into t01+00reg is read out, regardless of the t00mod setting. (example) operate tc00 and tc01 in the 16-bit timer mode with the operation clock of fcgck/2 [hz] and generate inter- rupts at 96 s intervals (fcgck = 10 mhz) ld (poffcr0),0x10 ; sets tc001en to "1" di ; sets the interrupt master enable flag to "disable" set (eirh).4 ; sets the inttc00 interrupt enable register to "1" ei ; sets the interrupt master enable flag to "enable" ld (t01mod),0xf0 ; selects the 16-bit timer mode and fcgck/2 ld (t00reg),0xe0 ; sets the timer register (96s / (2/fcgck) = 0x1e0) ld (t01reg),0x01 ; sets the timer register ld (t001cr),0x06 ; starts tc00 and tc001 (16-bit mode) tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 194 ra005
figure 14-11 16-bit timer counter timing chart tmp89ch42 page 195 ra005 source clock counter timer start 1 0 write to t00reg write m write r reflected by writing to t01reg reflected by writing to t01reg reflected by an interrupt reflected simultaneously by writing to t01reg while the timer is stopped counter clear inttc01 interrupt request 234 km-1 km 01 sr 01 220 3 t001cr timer stop counter clear km write to t01reg match detection write k write s write to t01reg write k write s t01+00reg sr sr-1 t01mod when the double buffer is disabled (t01mod=?0?) source clock counter timer start 1 0 km write to t00reg match detection write m write r counter clear inttc01 interrupt request 234 km-1 km 01 km 01 23 t01+00reg t001cr sr km double buffer sr match detection match detection counter clear 01 km-1 sr sr-1 t01mod when the double buffer is enabled (t01mod=?1?) reflected by writing to t01reg match detection
table 14-9 16-bit timer mode resolution and maximum time setting t01mod source clock [hz] resolution maximum time setting normal1/2 or idle1/2 mode slow1/2 or sleep1 mode fcgck=10mhz fs=32.768khz fcgck=10mhz fs=32.768khz syscr1 = "0" syscr1 = "1" 000 fcgck/2 11 fs/2 4 fs/2 4 204.8s 488.2s 13.4s 32s 001 fcgck/2 10 fs/2 3 fs/2 3 102.4s 244.1s 6.7s 16s 010 fcgck/2 8 fcgck/2 8 - 25.6s - 1.7s - 011 fcgck/2 6 fcgck/2 6 - 6.4s - 419.4ms - 100 fcgck/2 4 fcgck/2 4 - 1.6s - 104.9ms - 101 fcgck/2 2 fcgck/2 2 - 400ns - 26.2ms - 110 fcgck/2 fcgck/2 - 200ns - 13.1ms - 111 fcgck fcgck fs/2 2 100ns 122.1s 6.6ms 8s tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 196 ra005
14.4.6 16-bit event counter mode in the 16-bit event counter mode, the up counter counts up at the falling edge of the input to the tc00 pin. tc00 and tc01 are cascaded to form a 16-bit timer counter, which can measure a longer period than an 8-bit timer. 14.4.6.1 setting setting t001cr to "1" connects tc00 and tc01 and activates the 16-bit timer mode. all the settings of tc00 are ignored and those of tc01 are effective in the 16-bit timer mode. the 16-bit timer mode is activated by setting t01mod to "00" or "01" and t01mod to "1". set the count value to be used for the match detection as a 16-bit value at the timer registers t00reg and t01reg. set the lower 8 bits of the 16-bit value at t00reg and set the higher 8 bits at t01reg. (hereinafter, the 16-bit value specified by the combined setting of t01reg and t00reg is indicated as t01+00reg.) the timer register settings are reflected on the double buffer or t01+00reg when a write instruction is executed on t01reg. be sure to execute the write instructions on t00reg and t01reg in this order. (when data is written to the high-order register, the set values of the low-order and high-order registers become effective at the same time.) set t01mod to "1" to use the double buffer. setting t001cr to "1" starts the operation. after the timer is started, writing to t01mod becomes invalid. be sure to complete the required mode settings before starting the timer. (make settings when t001cr and are "0".) 14.4.6.2 operations setting t001cr to "1" allows the 16-bit up counter to increment at the falling edge of the tc00 pin. when a match between the up counter value and the t00+01reg set value is detected, an inttc01 interrupt request is generated and the up counter is cleared to "0x0000". after being cleared, the up counter restarts counting. setting t001cr to "0" during the timer operation makes the up counter stop counting and be cleared to "0x0000". the maximum frequency to be supplied is fcgck/2 [hz] (in normal1/2 or idle1/2 mode) or fs/2 4 [hz] (in slow1/2 or sleep1 mode), and a pulse width of two machine cycles or more is required at both the "h" and "l" levels. 14.4.6.3 double buffer refer to 14.4.5.3. tmp89ch42 page 197 ra005
(example) operate tc00 and tc01 in the 16-bit event counter mode and generate an interrupt each time the 384th falling edge is detected at the tc00 pin ld (poffcr0),0x10 ; sets tc001en to "1" di ; sets the interrupt master enable flag to "disable" set (eirh).4 ; sets the inttc00 interrupt enable register to "1" ei ; sets the interrupt master enable flag to "enable" ld (t00mod),0xc4 ; selects the 16-bit event counter mode ld (t00reg),0x80 ; sets the timer register ld (t01reg),0x10 ; sets the timer register ld (t001cr),0x06 ; starts tc00 and tc001 (16-bit mode) figure 14-12 16-bit event counter mode timing chart tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 198 ra005 tc00 pin input counter timer start when the double buffer is disabled (t01mod=?0?) 1 0 km write to t00reg match detection write m write s reflected by writing to t01reg reflected by writing to t01reg counter clear write to t01reg write k write r inttc00 interrupt request 23 4 km-1 km 01 rs 01 220 3 t01+00reg t001cr rs timer stop match detection counter clear counter clear rs-1 tc00 pin input counter timer start when the double buffer is enabled (t01mod=?1?) 1 0 km write to t00reg match detection write m write s reflected by writing to t01reg reflected by writing to t01reg counter clear write to t01reg write k write r inttc00 interrupt request 23 4 km-1 km 01 km 01 21 3 t01+00reg t001cr rs km double buffer rs m a t c h d e t e c t i o n counter clear counter clear km-1 rs 0 rs-1 m a t c h d e t e c t i o n reflected by an interrupt
14.4.7 12-bit pulse width modulation (pwm) output mode in the 12-bit pwm output mode, tc00 and tc01 are cascaded to output the pulse-width modulated pulses with a resolution of 8 bits. an additional pulse of 4 bits can be inserted, which enables pwm output with a resolution nearly equivalent to 12 bits. 14.4.7.1 setting setting t001cr to "1" connects tc00 and tc01 and activates the 16-bit timer mode. all the settings of tc00 are ignored and those of tc01 are effective in the 16-bit timer mode. the 12-bit pwm mode is selected by setting t01mod to "10". to use the internal clock as the source clock, set t01mod to "0" and select the clock at t01mod. to use an external clock as the source clock, set t01mod to "1". set t01mod to "1" to use the double buffer. setting t001cr to "1" starts the operation. after the timer is started, writing to t01mod becomes invalid. be sure to complete the required mode settings before starting the timer. (make settings when t001cr and are "0".) set the count value to be used for the match detection and the additional pulse value as a 12-bit value at the timer registers t00pwm and t01pwm. set bits 11 to 8 of the 12-bit value at the lower 4 bits of t01pwm and set bits 7 to 0 at t00pwm. refer to the following table for the register configuration. hereinafter, the 12-bit value specified by the combined setting of t00pwm and t01pwm is indicated as t01+00pwm. the timer register settings are reflected on the double buffer or t01+00pwm when a write instruction is executed on t01pwm. be sure to execute the write instructions on t00pwm and t01pwm in this order. (when data is written to the high-order register, the set values of the low-order and high-order registers become effective at the same time.) timer register 00 t00pwm 7 6 5 4 3 2 1 0 (0x0028) bit symbol pwmdutyl pwmad3 pwmad2 pwmad1 pwmad0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 1 1 1 1 1 1 1 1 timer register 01 t01pwm 7 6 5 4 3 2 1 0 (0x0029) bit symbol pwmdutyh read/write r/w r/w r/w r/w after reset 1 1 1 1 1 1 1 1 bits 7 to 4 of t01pwm are not used in the 12-bit pwm mode. however, data can be written to these bits of t01pwm and the written values are read out as they are when the bits are read. normally, set these bits to "0". pwmdutyh and pwmdutyl are 4-bit registers. they are combined to set an 8-bit value of duty pulse width (time before the first change in the output) for one cycle (256 counts of the source clock). hereinafter, an 8-bit value specified by the combined setting of pwmdutyh and pwmdutyl is indicated as pwmduty. pwmad3 to 0 are the additional pulse setting register. additional pulses can be inserted in specific cycles of the duty pulse by setting each bit to "1". the additional pulses are inserted in the positions listed in table 14-10 . pwmad 3 to 0 can be combined to specify the number of times of inserting the additional pulses in 16 cycles to any number from 1 to 16. examples of inserting additional pulses are shown in figure 14-13. tmp89ch42 page 199 ra005
table 14-10 cycles in which additional pulses are inserted cycles in which additional pulses are inserted among cycles 1 to 16 pwmad0="1" 9 pwmad1="1" 5, 13 pwmad2="1" 3, 7, 11, 15 pwmad3="1" 2, 4, 6, 8, 10, 12, 14, 16 set the initial state of the pwm1 pin at t01mod. setting t01mod to "0" selects the "l" level as the initial state of the pwm1 pin. setting t01mod to "1" selects the "h" level as the initial state of the pwm1 pin. if the pwm1 pin is set as the function output pin in the port setting while the timer is stopped, the value of t01mod is output to the pwm1 pin. table 14-11 shows the list of output levels of the pwm1 pin. table 14-11 list of output levels of pwm1 pin tff1 pwm1pin output level before the start of operation (initial state) pwmduty matched ( after the addition- al pulse) overflow operation stop- ped (initial state) 0 l h l l 1 h l h h tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 200 ra005
figure 14-13 examples of inserting additional pulses 14.4.7.2 operations setting t001cr to "1" allows the up counter to increment based on the selected source clock. when a match between the lower 8 bits of the up counter value and the value set to pwmduty is detected, the output of the pwm1 pin is reversed. when t01mod is "0", the pwm1 pin changes from the "l" to "h" level. when t01mod is "1", the pwm1 pin changes from the "h" to "l" level. if any of pwmad3 to 0 is "1", an additional pulse that corresponds to 1 count of the source clock is inserted in specific cycles of the duty pulse. in other words, the pwm1 pin output is reversed at the timing of pwmduty+1. when t00mod is "0", the period of the "l" level becomes longer than the value set to pwmduty by 1 source clock. when t00mod is "1", the period of the "h" level becomes longer than the value set to pwmduty by 1 source clock. this function allows 16 cycles of output pulses to be handled with a resolution nearly equivalent to 12 bits. no additional pulse is inserted when pwmad3 to 0 are all "0". subsequently, the up counter continues counting up. when the up counter value reaches 256, an overflow occurs and the up counter is cleared to "0x00". at the same time, the output of the pwm1 pin is reversed. when t01mod is "0", the pwm1 pin changes from the "h" to "l" level. when t01mod is "1", the pwm1 pin changes from the "l" to "h" level. at this time, an inttc00 interrupt request is generated (an inttc00 interrupt request is generated each time an overflow occurs.) an inttc01 interrupt request is generated at the 16 n-th overflow (n=1, 2, 3...). subsequently, the up counter continues counting up. tmp89ch42 page 201 ra005 timer start additional pulse 1234567891011121314151617 pwm1 pin output (tff1=?1?) timer stop timer stop pwm1 pin output (tff1=?0?) inttc00 interrupt request inttc01 interrupt request cycle when pwmad1=?1? additional pulse timer start 1234567891011121314151617 pwm1 pin output (tff1=?1?) pwm1 pin output (tff1=?0?) inttc00 interrupt request inttc01 interrupt request cycle when pwmad0 = ?1? and pwmad2 = ?1? additional pulse additional pulse additional pulse additional pulse additional pulse
when t001cr is set to "0" during the timer operation, the up counter is stopped and cleared to "0x00". the pwm1 pin returns to the level selected at t01mod. when an external source clock is selected, input the clock at the tc00 pin. the maximum frequency to be supplied is fcgck/2 [hz] (in normal1/2 or idle1/2 mode) or fs/2 4 [hz] (in slow1/2 or sleep1 mode), and a pulse width of two machine cycles or more is required at both the "h" and "l" levels. figure 14-14 pwm1 pin output 14.4.7.3 double buffer the double buffer can be used for t01+00pwm by setting t01mod. the double buffer is disabled by setting t01mod to "0" or enabled by setting t01mod to "1". ? when the double buffer is enabled when write instructions are executed on t00pwm and t01pwm in this order during the timer operation, the set value is first stored in the double buffer, and t01+00pwm is not updated im- mediately. t01+00pwm compares the previous set value with the up counter value. when the 16 n-th overflow occurs, an inttc01 interrupt request is generated and the double buffer set value is stored in t01+00pwm. subsequently, the match detection is executed using a new set value. when a read instruction is executed on t01+00pwm (t00reg), the value in the double buffer (the last set value) is read out, not the t01+00pwm value (the currently effective value). when write instructions are executed on t00pwm and t01pwm in this order while the timer is stopped, the set value is immediately stored in both the double buffer and t01+00pwm. ? when the double buffer is disabled when write instructions are executed on t00pwm and t01pwm in this order during the timer operation, the set value is immediately stored in t01+00pwm. subsequently, the match detection is executed using a new set value. if the value set to t01+00pwm is smaller than the up counter value, the pwm1 pin is not reversed until the up counter overflows and a match detection is executed using a new set value. if the value set to t01+00pwm is equal to the up counter value, the match detection is executed immediately after data is written into t01+00pwm. therefore, the timing of changing the pwm1 pin may not be an integral multiple of the source clock. simi- larly, if t01+00pwm is set during the additional pulse output, the timing of changing the pwm1 pin may not be an integral multiple of the source clock. if these are problems, enable the double buffer. when write instructions are executed on t00pwm and t01pwm in this order while the timer is stopped, the set value is immediately stored in t01+00pwm. tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 202 ra005 pwmduty timer start additional pulse (1 source clock) (duty pulse width) 256 counts (cycle width) 256 counts (cycle width) pwm1 pin output (tff0=?1?) pwmduty (duty pulse width) pwm1 pin output (tff0=?0?)
(example) operate tc00 and tc01 in the 12-bit pwm mode with the operation clock of fcgck/2 and output a duty pulse nearly equivalent to 14.0625 s in 51.2s cycles (fcgck = 10 mhz) (actually, output a duty pulse of 225 s in total in 16 cycles (819.2 s)) set (p7fc).1 ; sets p7fc1 to "1" set (p7cr).1 ; sets p7cr1 to "1" ld (poffcr0),0x10 ; sets tc001en to "1" di ; sets the interrupt master enable flag to "disable" set (eirh).4 ; sets the inttc00 interrupt enable register to "1" ei ; sets the interrupt master enable flag to "enable" ld (t01mod),0xf2 ; selects the 12-bit pwm mode and fcgck/2 ld (t00pwm),0x65 ; sets the timer register (duty pulse) ; (14.0625s 16) / (2/fcgck) = 0x465 ld (t01pwm),0x04 ; sets the timer register (duty pulse) ld (t001cr),0x06 ; starts tc00 and tc01 figure 14-15 12-bit pwm mode timing chart tmp89ch42 page 203 ra005 source clock counter timer start 1 0 km (0001) km km (duty pulse) 256 counts (cycle 1) 256 counts (cycle 2) 256 counts (cycle 9) 256 counts (cycle 16) (cycle 17) rs (0011) rs write to t00pwm double buffer match detection write m (0001) write s (0011) becomes the level selected at tff1 while the timer is stopped interrupt request interrupt request interrupt request write to t01pwm write k write r inttc00 interrupt request inttc01 interrupt request 1 km +1 km km +1 km km +1 km km +1 km 0 0001 0011 pwmduty pwmad3 to 0 t001cr 256 match detection 1 0 256 1 0 256 rs 1 0 256 match detection match detection counter clear overflow overflow overflow counter clear counter clear counter clear t01mod pwm1 pin output when the double buffer is enabled (t01mod=?1?) km (duty pulse) km (duty pulse) km+1 (duty pulse) rs (duty pulse) additional pulse interrupt request
table 14-12 resolutions and cycles in the 12-bit pwm mode t01mod source clock [hz] resolution 8-bit cycle (period 16) normal1/2 or idle1/2 mode slow1/2 or sleep1 mode fcgck=10mhz fs=32.768khz fcgck=10mhz fs=32.768khz syscr1 = "0" syscr1 = "1" 000 fcgck/2 11 fs/2 4 fs/2 4 204.8s 488.2s 52.4ms (838.9ms) 125ms (2000ms) 001 fcgck/2 10 fs/2 3 fs/2 3 102.4s 244.1s 26.2ms (419.4ms) 62.5ms (1000ms) 010 fcgck/2 8 fcgck/2 8 - 25.6s - 6.6ms (104.9ms) - 011 fcgck/2 6 fcgck/2 6 - 6.4s - 1.6ms (26.2ms) - 100 fcgck/2 4 fcgck/2 4 - 1.6s - 409.6s (6.6ms) - 101 fcgck/2 2 fcgck/2 2 - 400ns - 102.4s (1.6ms) - 110 fcgck/2 fcgck/2 - 200ns - 51.2s (819.2s) - 111 fcgck fcgck fs/2 2 100ns 122.1s 25.6s (409.6s) 31.3ms (500ms) tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 204 ra005
14.4.8 16-bit programmable pulse generate (ppg) output mode in the 16-bit ppg mode, tc00 and tc01 are cascaded to output the pulses that have a resolution of 16 bits and arbitrary pulse width and duty. two 16-bit registers, t01+00reg and t01+00pwm, are used to output the pulses. this enables output of longer pulses than an 8-bit timer. 14.4.8.1 setting setting t001cr to "1" connects tc00 and tc01 and activates the 16-bit mode. all the settings of tc00 are ignored and those of tc01 are effective in the 16-bit mode. the 16-bit ppg mode is selected by setting t01mod to "11". to use the internal clock as the source clock, set t01mod to "0" and select the clock at t01mod. to use an external clock as the source clock, set t01mod to "1". set t01mod to "1" to use the double buffer. set the count value that corresponds to a cycle as a 16-bit value at the timer registers t01reg and t00reg. set the count value that corresponds to a duty pulse as a 16-bit value at t01pwm and t00pwm (hereinafter, the 16-bit value specified by the combined setting of t01reg and t00reg is indicated as t01+00reg, and the 16-bit value specified by the combined setting of t01pwm and t00pwm is indicated as t01+00pwm). the timer register settings are reflected on the double buffer or t01+00pwm and t01+00reg when a write instruction is executed on t01pwm. be sure to execute the write instructions on t00reg, t01reg and t00pwm before executing a write instruction on t01pwm. (when data is written to t01pwm, the set values of the four timer registers become effective at the same time.) set the initial state of the ppg1 pin at t01mod. setting t01mod to "0" selects the "l" level as the initial state of the ppg1 pin. setting t01mod to "1" selects the "h" level as the initial state of the ppg1 pin. if the ppg1 pin is set as the function output pin in the port setting while the timer is stopped, the value of t01mod is output to the ppg1 pin. table 14-13 shows the list of output levels of the ppg1 pin. table 14-13 list of output levels of ppg1 pin tff1 ppg1 pin output level before the start of operation (initial state) t01+00pwm matched t01+00reg matched operation stop- ped (initial state) 0 l h l l 1 h l h h 14.4.8.2 operations setting t001cr to "1" allows the up counter to increment based on the selected source clock. when a match between the up counter value and the value set to t01+00pwm is detected, the output of the ppg1 pin is reversed. when t01mod is "0", the ppg1 pin changes from the "l" to "h" level. when t01mod is "1", the ppg1 pin changes from the "h" to "l" level. at this time, an inttc00 interrupt request is generated. the up counter continues counting up. when a match between the up counter value and the value set to t01+00reg is detected, the output of the ppg1 pin is reversed again. when t01mod is "0", the ppg1 pin changes from the "h" to "l" level. when t01mod is "1", the ppg1 pin changes from the "l" to "h" level. at this time, an inttc01 interrupt request is generated and the up counter is cleared to "0x0000". when t001cr is set to "0" during the timer operation, the up counter is stopped and cleared to "0x0000". the ppg1 pin returns to the level selected at t01mod. tmp89ch42 page 205 ra005
when an external source clock is selected, input the clock at the tc00 pin. the maximum frequency to be supplied is fcgck/2 [hz] (in normal1/2 or idle1/2 mode) or fs/2 4 [hz] (in slow1/2 or sleep1 mode), and a pulse width of two machine cycles or more is required at both the "h" and "l" levels. 14.4.8.3 double buffer the double buffer can be used for t01+00pwm and t01+00reg by setting t01mod. the double buffer is enabled by setting t01mod to "0" or disabled by setting t01mod to "1". ? when the double buffer is enabled when a write instruction is executed on t01pwm after write instructions are executed on t00reg, t01reg and t00pwm during the timer operation, the set values are first stored in the double buffer, and t01+00pwm and t01+00reg are not updated immediately. t01+00pwm and t01+00reg compare the previous set values with the up counter value. when a match be- tween the up counter value and the t01+00reg set value is detected, an inttc01 interrupt request is generated and the double buffer set values are stored in t01+00pwm and t01+00reg. subsequently, the match detection is executed using new set values. when a write instruction is executed on t01pwm after write instructions are executed on t00reg, t01reg and t00pwm while the timer is stopped, the set values are immediately stored in both the double buffer and t01+00pwm and t01+00reg. ? when the double buffer is disabled when a write instruction is executed on t01pwm after write instructions are executed on t00reg, t01reg and t00pwm during the timer operation, the set values are immediately stored in t01+00pwm and t01+00reg. subsequently, the match detection is executed using new set values. if the value set to t01+00pwm or t01+00reg is smaller than the up counter value, the ppg1 pin is not reversed until the up counter overflows and a match detection is executed using a new set value. if the value set to t01+00pwm or t01+00reg is equal to the up counter value, the match detection is executed immediately after data is written into t01+00pwm and t01 +00reg. therefore, the timing of changing the ppg1 pin may not be an integral multiple of the source clock. if these are problems, enable the double buffer. when a write instruction is executed on t01pwm after write instructions are executed on t00reg, t01reg and t00pwm while the timer is stopped, the set values are immediately stored in t01+00pwm and t01+00reg. when read instructions are executed on t01+00pwm and t01+00reg, the last value written into t01 +00reg is read out, regardless of the t00mod setting. tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 206 ra005
(example) operate tc00 and tc01 in the 16-bit ppg mode with the operation clock of fcgck/2 and output the 68s duty pulse in 96s cycles (fcgck = 10 mhz) set (p7fc).1 ; sets p7fc0 to "1" set (p7cr).1 ; sets p7cr0 to "1" ld (poffcr0),0x10 ; sets tc001en to "1" di ; sets the interrupt master enable flag to "disable" set (eirh).4 ; sets the inttc00 interrupt enable register to "1" ei ; sets the interrupt master enable flag to "enable" ld (t01mod),0xf3 ; selects the 8-bit ppg mode and fcgck/2 ld (t00reg),0xe0 ; sets the timer register (cycle) ld (t01reg),0x01 ; sets the timer register (cycle) ; 96s / (2/fcgck) = 0x01e0 ld (t00pwm),0x54 ; sets the timer register (duty pulse) ld (t01pwm),0x01 ; sets the timer register (duty pulse) ; 68s / (2/fcgck) = 0x0154 ld (t001cr),0x06 ; starts tc00 and tc01 tmp89ch42 page 207 ra005
figure 14-16 16-bit ppg output mode timing chart tmp89ch42 14. 8-bit timer counter (tc0) 14.4 functions page 208 ra005 source clock counter timer start 1 0 gh gh gh (duty pulse) ab (cycle 1) cd (cycle 1) cd (cycle 1) ef (cycle 1) km qr km qr write to t00pwm double buffer match detection write h write m write r becomes the level selected at tff1 while the timer is stopped returns to the level selected at tff1 write to t01pwm write g write k write q inttc00 interrupt request inttc00 interrupt request 1 gh +1 km +1 gh 0 t01+00pwm t001cr ab cd ef write to t01reg double buffer write a write c write e write to t00reg write b write d write f ab timer stop match detection km km +1 km qr +1 qr 1 0 cd 1 0 cd 1 00 ef match detection counter clear counter clear counter clear counter clear t01mod ppg1 pin output when the double buffer is enabled (t01mod=?1?) km (duty pulse) km (duty pulse) qr (duty pulse) ab cd ef t01+00reg match detection match detection match detection match detection match detection
14.5 revision history rev description ra003 revised interrupt name from "intt00" and "intt01" to "inttc00" and "inttc01". added upper bar to pwm and ppg label. ra004 "14.4.3 8-bit pulse width modulation (pwm) output mode" revised exsample program. "figure 14-15 12-bit pwm mode timing chart" revised each item name. ra005 "figure 14-1 8-bit timer counters 00 and 01" revised source clock from "fc" to "fcgck". "14.4.7 12-bit pulse width modulation (pwm) output mode" revised example program. tmp89ch42 page 209 ra005
tmp89ch42 14. 8-bit timer counter (tc0) 14.5 revision history page 210 ra005
15. real time clock (rtc) the real time clock is a function that generates interrupt requests at certain intervals using the low-frequency clock. the number of interrupts is counted by the software to realize the clock function. the real time clock can be used only in the operation modes where the low-frequency clock oscillates, except for sleep0. 15.1 configuration figure 15-1 real time clock 15.2 control the real time clock is controlled by following resisters. low power consumption register 2 poffcr2 7 6 5 4 3 2 1 0 (0x0f76) bit symbol - - rtcen - - - - sio0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 rtcen rtc control 0 1 disable enable sio0en sio0 control 0 1 disable enable tmp89ch42 page 211 ra000 rtcsel rtcrun intrtc interrupt request fs (32.768 khz) rtccr selector binary counter 2 15 /fs 2 14 /fs 2 13 /fs 2 12 /fs 2 11 /fs 2 10 /fs 2 9 /fs 2 8 /fs
real time clock control register rtccr (0x0fc8) 7 6 5 4 3 2 1 0 bit symbol - - - - rtcsel rtcrun read/write r r r r r/w r/w after reset 0 0 0 0 0 0 0 0 rtcsel selects the interrupt generation interval 000 : 2 15 /fs (1.000 [s] @fs=32.768khz) 001 : 2 14 /fs (0.500 [s] @fs=32.768khz) 010 : 2 13 /fs (0.250 [s] @fs=32.768khz) 011 : 2 12 /fs (125.0 [ms] @fs=32.768khz) 100 : 2 11 /fs (62.50 [ms] @fs=32.768khz) 101 : 2 10 /fs (31.25 [ms] @fs=32.768khz) 110 : 2 9 /fs (15.62 [ms] @fs=32.768khz) 111 : 2 8 /fs (7.81 [ms] @fs=32.768khz) rtcrun enables/disables the real time clock opera- tion 0 : disable 1 : enable note 1: fs: low-frequency clock [hz] note 2: rtccr can be rewritten only when rtccr is "0". if data is written into rtccr when rtccr is "1", the existing data remains effective. rtccr can be rewritten at the same time as enabling the real time clock, but it cannot be rewritten at the same time as disabling the real time clock. note 3: if the real time clock is enabled and when 1) syscr2 is cleared to "0" to stop the low-frequency clock oscillation circuit or 2) the operation is changed to the stop mode or the sleep0 mode, the data in rtccr is maintained and rtccr is cleared to "0". 15.3 function 15.3.1 low power consumption function real time clock has the low power consumption registers (poffcr 2 ) that save power when the real time clock is not being used. setting poffcr 2 to "0" disables the basic clock supply to real time clock to save power. note that this renders the real time clock unusable. setting poffcr 2 to "1" enables the basic clock supply to real time clock and allows the real time clock to operate. after reset, poffcr 2 are initialized to "0", and this renders the real time clock unusable. when using the real time clock for the first time, be sure to set poffcr 2 to "1" in the initial setting of the program (before the real time clock control registers are operated). do not change poffcr 2 to "0" during the real time clock operation. otherwise real time clock may operate unexpectedly. 15.3.2 enabling/disabling the real time clock operation setting rtccr to "1" enables the real time clock operation. setting rtccr to "0" disables the real time clock operation. rtccr is cleared to "0" just after reset release. 15.3.3 selecting the interrupt generation interval the interrupt generation interval can be selected at rtccr. tmp89ch42 15. real time clock (rtc) 15.3 function page 212 ra000
rtccr can be rewritten only when rtccr is "0". if data is written into rtccr when rtccr is "1", the existing data remains effective. rtccr can be rewritten at the same time as enabling the real time clock operation, but it cannot be rewritten at the same time as disabling the real time clock operation. 15.4 real time clock operation 15.4.1 enabling the real time clock operation set the interrupt generation interval to rtccr, and at the same time, set rtccr to "1". when rtccr is set to "1", the binary counter for the real time clock starts counting of the low- frequency clock. when the interrupt generation interval selected at rtccr is reached, a real time clock interrupt request (intrtc) is generated and the counter continues counting. 15.4.2 disabling the real time clock operation clear rtccr to "0". when rtccr is cleared to "0", the binary counter for the real time clock is cleared to "0" and stops counting of the low-frequency clock. tmp89ch42 page 213 ra000
tmp89ch42 15. real time clock (rtc) 15.4 real time clock operation page 214 ra000
16. asynchronous serial interface (uart) the tmp89ch42 contains 2 channels of asynchronous serial interfaces (uart). this chapter describes asynchronous serial interface 0 (uart0). for uart1, replace the sfr addresses and pin names as shown in table 16-1 and table 16-2. table 16-1 sfr address assignment uartxcr1 (address) uartxcr2 (address) uartxdr (address) uartxsr (address) rdxbuf (address) tdxbuf (address) uart0 uart0cr1 (0x001a) uart0cr2 (0x001b) uart0dr (0x001c) uart0sr (0x001d) rd0buf (0x001e) td0buf (0x001e) uart1 uart1cr1 (0x0f54) uart1cr2 (0x0f55) uart1dr (0x0f56) uart1sr (0x0f57) rd1buf (0x0f58) td1buf (0x0f58) table 16-2 pin names serial data input pin serial data output pin uart0 rxd0 pin txd0 pin uart1 rxd1 pin txd1 pin tmp89ch42 page 215 ra001
16.1 configuration figure 16-1 asynchronous serial interface (uart) tmp89ch42 16. asynchronous serial interface (uart) 16.1 configuration page 216 ra001 8-bit counter 8-bit counter y a b c s s a by fcgck or fs match detection en en match detection comparator comparator start bit detection transmission start stop bit parity bit fcgck/2 6 fcgck/2 7 fcgck/2 8 ppga0 output (tca0 output) baud rate generator transmit rt clock receive rt clock 2 4 2 2 2 noise rejection circuit shift register shift register irda control s a by counter counter transmit control circuit receive control circuit selector frequency divider uart0cr1 uart0 control register 1 inttxd0 interrupt request intrxd0 interrupt request uart0 transmit data buffer uart0 receive data buffer rxd0 txd0 uart0cr1 rd0buf uart0cr2 uart0sr uart0dr uart0 baud rate register uart0 status register uart0 control register 2
16.2 control uart0 is controlled by the low power consumption registers (poffcr 1 ), uart0 control registers 1 and 2 (uart0cr1 and uart0cr2) and the uart0 baud rate register (uart0dr). the operating status can be monitored using the uart status register (uart0sr). low power consumption register 1 poffcr1 7 6 5 4 3 2 1 0 (0x0f75) bit symbol - - - sbi0en - - uart1en uart0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 sbi0en i2c0 control 0 1 disable enable uart1en uart1 control 0 1 disable enable uart0en uart0 control 0 1 disable enable tmp89ch42 page 217 ra001
uart0 control register 1 uart0cr1 7 6 5 4 3 2 1 0 (0x001a) bit symbol txe rxe stopbt even pe irdasel brg - read/write r/w r/w r/w r/w r/w r/w r/w r after reset 0 0 0 0 0 0 0 0 txe transmit operation 0: 1: disable enable rxe receive operation 0: 1: disable enable stopbt transmit stop bit length 0: 1: 1 bit 2 bits even parity selection 0: 1: odd-numbered parity even-numbered parity pe parity addition 0: 1: no parity parity added irdasel txd pin output selection 0: 1: uart output irda output brg transfer base clock selection when syscr2 is "0" when syscr2 is "1" 0: fcgck fs 1: tca0 output note 1: fcgck, gear clock; fs, low-frequency clock note 2: if the txe or rxe bit is set to "0" during the transmission or receiving of data, the operation is not disabled until the data transfer is completed. at this time, the data stored in the transmit data buffer is discarded. note 3: even, pe and brg settings are common to transmission and receiving. note 4: set rxe and txe to "0" before changing brg. note 5: when brg is set to the tca0 output, the rt clock becomes asynchronous and the start bit of the transmitted/received data may get shorter by a maximum of (uart0dr+1)/(transfer base clock frequency)[s]. if the pin is not used for the tca0 output, control the tca0 output by using the port function control register. note 6: to prevent stopbt, even, pe, irdasel and brg from being changed accidentally during the uart communication, the register cannot be rewritten during the uart operation. for details, refer to "16.4 protection to prevent uart0cr1 and uart0cr2 registers from being changed ". note 7: when the stop, idle0 or sleep0 mode is activated, txe and rxe are cleared to "0" and the uart stops. other bits keep their values. tmp89ch42 16. asynchronous serial interface (uart) 16.2 control page 218 ra001
uart0 control register 2 uart0cr2 7 6 5 4 3 2 1 0 (0x001b) bit symbol - - rtsel rxdnc stopbr read/write r r r/w r/w r/w after reset 0 0 0 0 0 0 0 0 rtsel selects the number of rt clocks odd-numbered bits of transfer frame even-numbered bits of transfer frame 000: 16 clocks 16 clocks 001: 16 clocks 17 clocks 010: 15 clocks 15 clocks 011: 15 clocks 16 clocks 100: 17 clocks 17 clocks 101: reserved 11*: reserved rxdnc selects the rxd input noise rejec- tion time (time of pulses to be removed as noise) 00: 01: 10: 11: no noise rejection 1 x (uart0dr+1)/(transfer base clock frequency) [s] 2 x (uart0dr+1)/(transfer base clock frequency) [s] 4 x (uart0dr+1)/(transfer base clock frequency) [s] stopbr receive stop bit length 0: 1: 1 bit 2 bits note 1: when a read instruction is executed on uart0cr2, bits 7 and 6 are read as "0". note 2: rtsel can be set to two kinds of rt clocks for the even- and odd-numbered bits of the transfer frame. for details, refer to "16.8.1 transfer baud rate calculation method". note 3: for details of the rxdnc noise rejection time, refer to "16.10 received data noise rejection". note 4: when the stop, idle0 or sleep0 mode is activated, the uart stops automatically but each bit value of uart0cr2 remains unchanged. note 5: when stopbr is set to 2 bits, the first bit of the stop bits (during data receiving) is not checked for a framing error. note 6: to prevent rtsel, rxdnc and stopbr from being changed accidentally during the uart communication, the register cannot be rewritten during the uart operation. for details, refer to "16.4 protection to prevent uart0cr1 and uart0cr2 registers from being changed ". uart0 baud rate register uart0dr 7 6 5 4 3 2 1 0 (0x001c) bit symbol uart0dr7 uart0dr6 uart0dr5 uart0dr4 uart0dr3 uart0dr2 uart0dr1 uart0dr0 read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 note 1: set uart0cr1 and uart0cr1 to "0" before changing uart0dr. for the set values, refer to "16.8 transfer baud rate". note 2: when uart0cr1 is set to the tca0 output, the value set to uart0dr has no meaning. note 3: when the stop, idle0 or sleep0 mode is activated, the uart stops automatically but each bit value of uart0dr remains unchanged. tmp89ch42 page 219 ra001
uart0 status register uart0sr 7 6 5 4 3 2 1 0 (0x001d) bit symbol perr ferr oerr - rbsy rbfl tbsy tbfl read/write r r r r r r r r after reset 0 0 0 0 0 0 0 0 perr parity error flag 0: 1: no parity error parity error ferr framing error flag 0: 1: no framing error framing error oerr overrun error flag 0: 1: no overrrun error overrun error rbsy receive busy flag 0: 1: before receiving or end of receiving on receiving rbfl receive buffer full flag 0: 1: receive buffer empty receive buffer full tbsy transmit busy flag 0: 1: before transmission or end of transmission on transmitting tbfl transmit buffer full flag 0: 1: transmit buffer empty transmit buffer full (transmit data writing is completed) note 1: tbfl is cleared to "0" automatically after an inttxd0 interrupt request is generated, and is set to "1" when data is set to td0buf. note 2: when a read instruction is executed on uart0sr, bit 4 is read as "0". note 3: when the stop, idle0 or sleep0 mode is activated, each bit of uart0sr is cleared to "0" and the uart stops. uart0 receive data buffer rd0buf 7 6 5 4 3 2 1 0 (0x001e) bit symbol rd0dr7 rd0dr6 rd0dr5 rd0dr4 rd0dr3 rd0dr2 rd0dr1 rd0dr0 read/write r r r r r r r r after reset 0 0 0 0 0 0 0 0 note 1: when the stop, idle0 or sleep0 mode is activated, the rd0buf values become undefined. if received data is required, read it before activating the mode. uart0 transmit data buffer td0buf 7 6 5 4 3 2 1 0 (0x001e) bit symbol td0dr7 td0dr6 td0dr5 td0dr4 td0dr3 td0dr2 td0dr1 td0dr0 read/write w w w w w w w w after reset 0 0 0 0 0 0 0 0 note 1: when the stop, idle0 or sleep0 mode is activated, the td0buf values become undefined. tmp89ch42 16. asynchronous serial interface (uart) 16.2 control page 220 ra001
16.3 low power consumption function uart0 has a low power consumption register (poffcr 1 ) that saves power consumption when the uart function is not used. setting poffcr 1 to "0" disables the basic clock supply to uart0 to save power. note that this renders the uart unusable. setting poffcr 1 to "1" enables the basic clock supply to uart0 and renders the uart usable. after reset, poffcr 1 is initialized to "0", and this renders the uart unusable. when using the uart for the first time, be sure to set poffcr 1 to "1" in the initial setting of the program (before the uart control register is operated). do not change poffcr1 to "0" during the uart operation, otherwise uart0 may operate unex- pectedly. tmp89ch42 page 221 ra001
16.4 protection to prevent uart0cr1 and uart0cr2 registers from being changed the tmp89ch42 has a function that protects the registers from being changed so that the uart communication settings (for example, stop bit and parity) are not changed accidentally during the uart operation. specific bits of uart0cr1 and uart0cr2 can be changed only under the conditions shown in table 16-3. if a write instruction is executed on the register when it is protected from being changed, the bits remain unchanged and keep their previous values. table 16-3 changing of uart0cr1 and uart0cr2 bit to be changed function conditions that allow the bit to be changed uart0cr1 uart0sr uart0cr1 uart0sr uart0cr1 transmit stop bit length both of these bits are "0" - - uart0cr1 parity selection all of these bits are "0" uart0cr1 parity addition uart0cr1 txd pin output selection both of these bits are "0" - - uart0cr1 transfer base clock selection all of these bits are "0" uart0cr2 selection of number of rt clocks uart0cr2 selection of rxd pin input noise rejection time - - both of these bits are "0" uart0cr2 receive stop bit length tmp89ch42 16. asynchronous serial interface (uart) 16.4 protection to prevent uart0cr1 and uart0cr2 registers from being changed page 222 ra001
16.5 activation of stop, idle0 or sleep0 mode 16.5.1 transition of register status when the stop, idle0 or sleep0 mode is activated, the uart stops automatically and each register be- comes the status as shown in table 16-4 . for the registers that do not hold their values, make settings again as needed after the operation mode is recovered. table 16-4 transition of register status 7 6 5 4 3 2 1 0 uart0cr1 txe rxe stopbt even pe irdasel brg - cleared to 0 cleared to 0 hold the val- ue hold the val- ue hold the val- ue hold the val- ue hold the val- ue - uart0cr2 - - rtsel rxdnc stopbr - - hold the val- ue hold the val- ue hold the val- ue hold the val- ue hold the val- ue hold the val- ue uart0sr perr ferr oerr - rbsy rbfl tbsy tbfl cleared to 0 cleared to 0 cleared to 0 - cleared to 0 cleared to 0 cleared to 0 cleared to 0 uart0dr uart0dr7 uart0dr6 uart0dr5 uart0dr4 uart0dr3 uart0dr2 uart0dr1 uart0dr0 hold the val- ue hold the val- ue hold the val- ue hold the val- ue hold the val- ue hold the val- ue hold the val- ue hold the val- ue rd0buf rd0dr7 rd0dr6 rd0dr5 rd0dr4 rd0dr3 rd0dr2 rd0dr1 rd0dr0 indetermi- nate indetermi- nate indetermi- nate indetermi- nate indetermi- nate indetermi- nate indetermi- nate indetermi- nate td0buf td0dr7 td0dr6 td0dr5 td0dr4 td0dr3 td0dr2 td0dr1 td0dr0 indetermi- nate indetermi- nate indetermi- nate indetermi- nate indetermi- nate indetermi- nate indetermi- nate indetermi- nate 16.5.2 transition of txd pin status when the idle0, sleep0 or stop mode is activated, the txd pin reverts to the status shown in table 16-5, whether data is transmitted/received or the operation is stopped. table 16-5 txd pin status when the stop, idle0 or sleep0 mode is activated uart0cr1 idle0 or sleep0 mode stop mode syscr1="1" syscr1="0" "0" h level h level hi-z "1" l level l level tmp89ch42 page 223 ra001
16.6 transfer data format the uart transfers data composed of the following four elements. the data from the start bit to the stop bit is collectively defined as a "transfer frame". the start bit consists of 1 bit (l level) and the data consists of 8 bits. parity bits are determined by uart0cr1 that selects the presence or absence of parity and uart0cr1 that selects even- or odd-numbered parity. the bit length of the stop bit can be selected at uart0cr1. figure 16-2 shows the transfer data format. ? start bit (1 bit) ? data (8 bits) ? parity bit (selectable from even-numbered, odd-numbered or no parity) ? stop bit (selectable from 1 bit or 2 bits) figure 16-2 transfer data format 16.7 infrared data format transfer mode the txd0 pin can output data in the infrared data format (irda) by the setting of the irda output control register. setting uart0cr1 to "1" allows the txd0 pin to output data in the infrared data format. figure 16-3 example of infrared data format (comparison between normal output and irda output) tmp89ch42 16. asynchronous serial interface (uart) 16.6 transfer data format page 224 ra001 uart output irda output start bit stop bit d0 d1 d2 d7 3/16 bit width start 123456789101112 bit 0 stop 1 start bit 0 stop 1 stop 2 stop 1 stop 1 stop 2 start bit 0 bit 0 start bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 parity parity bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 0 1 0 1 0 0 1 1 stbt pe transfer frame
16.8 transfer baud rate the transfer baud rate of uart is set by uart0cr1, uart0dr and uart0cr2. the settings of uart0dr and uart0cr2 for general baud rates and operating frequencies are shown below. for independent calculation of transfer baud rates, refer to "16.8.1 transfer baud rate calculation method". table 16-6 set values of uart0dr and uart0cr2 for transfer baud rates (fcgck=10 to 1 mhz, uart0cr2=0y00) basic baud rate [baud] register operating frequency 10mhz 8mhz 7.3728 mhz 6.144 mhz 6mhz 5mhz 4.9152 mhz 4.19mhz 4mhz 2mhz 1mhz 128000 uart0dr 0x04 0x03 - 0x02 0x02 - - 0x01 0x01 0x00 - rtsel 0y011 0y011 - 0y000 0y011 - - 0y001 0y011 0y011 - error (+0.81%) (+0.81%) - (0%) (+0.81%) - - (-0.80%) (+0.81%) (+0.81%) - 115200 uart0dr 0x04 0x03 0x03 - 0x02 - - - 0x01 0x00 - rtsel 0y100 0y100 0y000 - 0y100 - - - 0y100 0y100 - error (+2.12%) (+2.12%) (0%) - (+2.12%) - - - (+2.12%) (+2.12%) - 76800 uart0dr 0x07 0x06 0x05 0x04 0x04 0x03 0x03 - 0x02 - - rtsel 0y001 0y010 0y000 0y000 0y011 0y001 0y000 - 0y100 - - error (-1.36%) (-0.79%) (0%) (0%) (+0.81%) (-1.36%) (0%) - (+2.12%) - - 62500 uart0dr 0x09 0x07 0x06 0x05 0x05 0x04 0x04 0x03 0x03 0x01 0x00 rtsel 0y000 0y000 0y100 0y001 0y000 0y000 0y011 0y100 0y000 0y000 0y000 error (0%) (0%) (-0.87%) (-0.70%) (0%) (0%) (+1.48%) (-1.41%) (0%) (0%) (0%) 57600 uart0dr 0x0a 0x08 0x07 0x06 0x06 0x04 0x04 - 0x03 0x01 0x00 rtsel 0y000 0y011 0y000 0y010 0y010 0y100 0y100 - 0y100 0y100 0y100 error (-1.36%) (-0.44%) (0%) (+1.59%) (-0.79%) (+2.12%) (+0.39%) - (+2.12%) (+2.12%) (+2.12%) 38400 uart0dr 0x10 0x0c 0x0b 0x09 0x09 0x07 0x07 0x06 0x06 0x02 - rtsel 0y011 0y000 0y000 0y000 0y011 0y001 0y000 0y011 0y010 0y100 - error (-1.17%) (+0.16%) (0%) (0%) (+0.81%) (-1.36%) (0%) (+0.57%) (-0.79%) (+2.12%) - 19200 uart0dr 0x22 0x19 0x17 0x13 0x12 0x10 0x0f 0x0d 0x0c 0x06 0x02 rtsel 0y010 0y000 0y000 0y000 0y001 0y011 0y000 0y011 0y000 0y010 0y100 error (-0.79%) (+0.16%) (0%) (0%) (-0.32%) (-1.17%) (0%) (+0.57%) (+0.16%) (-0.79%) (+2.12%) 9600 uart0dr 0x40 0x30 0x2f 0x27 0x26 0x22 0x1f 0x1c 0x19 0x0c 0x06 rtsel 0y000 0y100 0y000 0y000 0y000 0y010 0y000 0y010 0y000 0y000 0y010 error (+0.16%) (+0.04%) (0%) (0%) (+0.16%) (-0.79%) (0%) (+0.34%) (+0.16%) (+0.16%) (-0.79%) 4800 uart0dr 0x8a 0x64 0x5f 0x4f 0x4d 0x40 0x3f 0x34 0x30 0x19 0x0c rtsel 0y010 0y001 0y000 0y000 0y000 0y000 0y000 0y001 0y100 0y000 0y000 error (-0.08%) (+0.01%) (0%) (0%) (+0.16%) (+0.16%) (0%) (-0.18%) (+0.04%) (+0.16%) (+0.16%) 2400 uart0dr 0xf4 0xc9 0xbf 0x9f 0x92 0x8a 0x7f 0x6c 0x64 0x30 0x19 rtsel 0y100 0y001 0y000 0y000 0y100 0y010 0y000 0y000 0y001 0y100 0y000 error (+0.04%) (+0.01%) (0%) (0%) (+0.04%) (-0.08%) (0%) (+0.11%) (+0.01%) (+0.04%) (+0.16%) 1200 uart0dr - - - - - 0xf4 0xff 0xe8 0xc9 0x64 0x30 rtsel - - - - - 0y100 0y000 0y010 0y001 0y001 0y100 error - - - - - (+0.04%) (+0%) (-0.10%) (+0.01%) (+0.01%) (+0.04%) tmp89ch42 page 225 ra001
table 16-7 set values of uart0dr and uart0cr2 for transfer baud rates (fs=32.768 khz, uart0cr2=0y00) basic baud rate [baud] register operating frequency 32.768 khz 300 uart0dr 0x06 rtsel 0y011 error (+0.67%) 150 uart0dr 0x0d rtsel 0y011 error (+0.67%) 134 uart0dr 0x0e rtsel 0y001 error (-1.20%) 110 uart0dr 0x11 rtsel 0y001 error (+0.30%) 75 uart0dr 0x1c rtsel 0y010 error (+0.44%) note 1: the overall error from the basic baud rate must be within 3%. even if the overall error is within 3%, the communication may fail due to factors such as frequency errors in external controllers (for example, a personal computer) and oscillators and the load capacity of the communication pin. 16.8.1 transfer baud rate calculation method 16.8.1.1 bit width adjustment using uart0cr2 the bit width of transmitted/received data can be finely adjusted by changing uart0cr2. the number of rt clocks per bit can be changed in a range of 15 to 17 clocks by changing uart0cr2. the rt clock is the transfer base clock, which is the pulses obtained by counting the clock selected at uart0cr1 the number of times of (uart0dr set value) + 1. especially, when uart0cr2 is set to "0y001" or "0y011", two types of rt clocks alternate at each bit, so that the pseudo baud rates of rt 15.5 clocks and rt 16.5 clocks can be generated. the number of rt clocks per bit of transfer frame is shown in figure 16-4. for example, when fcgck is 4 [mhz], uart0cr2 is set to "0y000" and uart0dr is set to "0x19", the baud rate calculated using the formula in figure 16-4 is expressed as: fcgck / (16 (uart0dr + 1) = 9615 [baud] these settings generate a baud rate close to 9600 [baud] (+0.16%). tmp89ch42 16. asynchronous serial interface (uart) 16.8 transfer baud rate page 226 ra001
figure 16-4 fine adjustment of baud rate clock using uart0cr2 16.8.1.2 calculation of set values of uart0cr2 and uart0dr the set value of uart0dr for an operating frequency and baud rate can be calculated using the calculation formula shown in figure 16-5. for example, to generate a basic baud rate of 38400 [baud] with fcgck=4 [mhz], calculate the set value of uart0dr for each setting of uart0cr2 and compensate the calculated value to a positive number to obtain the generated baud rate as shown in figure 16-6. basically, select the set value of uart0cr2 that has the smallest baud rate error from among the generated baud rates. in figure 16-6 , the setting of uart0cr2="0y010" has the smallest error among the calculated baud rates, and thus the generated baud rate is 38095 [baud] (?0.79%) against the basic baud rate of 38400 [baud]. note: the error from the basic baud rate should be accurate to within 3%. even if the error is within 3%, the communication may fail due to factors such as frequency errors of external controllers (for example, a personal computer) and oscillators and the load capacity of the communication pin. figure 16-5 uart0dr calculation method (when brg is set to fcgck) tmp89ch42 page 227 ra001 000 fcgck [hz] 1 1 1 1 1 uartdr = 16 a [baud] uartdr set value rtsel 001 fcgck [hz] uartdr = 16.5 a [baud] 010 fcgck [hz] uartdr = 15 a [baud] 011 fcgck [hz] uartdr = 15.5 a [baud] 100 fcgck [hz] uartdr = 17 a [baud] start 123456789101112 bit 0 stop 1 start bit 0 stop 1 stop 2 stop 1 stop 1 stop 2 start bit 0 bit 0 start bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 parity parity bit 1 bit 2 bit 3 bit 4 bit 5 bit 6 bit 7 0 1 0 1 0 0 1 1 stbt pe 000 001 010 011 100 16 16 15 15 17 16 17 15 16 17 16 16 15 15 17 16 17 15 16 17 16 16 15 15 17 16 17 15 16 17 16 16 15 15 17 16 17 15 16 17 16 16 15 15 17 16 17 15 16 17 16 16 15 15 17 16 fcgck [baud] 16 (uartdr+1) generated baud rate *when brg is set to fcgck 17 15 16 17 rtsel transfer frame fcgck [baud] 16.5 (uartdr+1) fcgck [baud] 15 (uartdr+1) fcgck [baud] 15.5 (uartdr+1) fcgck [baud] 17 (uartdr+1) number of rt clocks
figure 16-6 example of uart0dr calculation tmp89ch42 16. asynchronous serial interface (uart) 16.8 transfer baud rate page 228 ra001 000 4000000 [hz] 4000000 [hz] 4000000 [hz] 4000000 [hz] 4000000 [hz] 1 6 35714 [baud] ( 6.99%) 40404 [baud] ( 5.22%) 38095 [baud] ( 0.79%) 36866 [baud] ( 3.99%) 39216 [baud] ( 2.12%) 1 6 1 6 1 5 1 5 uartdr = 16 38400 [baud] uartdr calculation generated baud rate rtsel 4000000 [hz] 16 (6 + 1) 4000000 [hz] 16.5 (5 + 1) 4000000 [hz] 15 (6 + 1) 4000000 [hz] 15.5 (6 + 1) 4000000 [hz] 17 (5 + 1) 001 uartdr = 16.5 38400 [baud] 010 uartdr = 15 38400 [baud] 011 uartdr = 15.5 38400 [baud] 100 uartdr = 17 38400 [baud]
16.9 data sampling method the uart receive control circuit starts rt clock counting when it detects a falling edge of the input pulses to the rxd0 pin. 15 to 17 rt clocks are counted per bit and each clock is expressed as rtn (n=16 to 0). in a bit that has 17 rt clocks, rt16 to rt0 are counted. in a bit that has 16 rt clocks, rt15 to rt0 are counted. in a bit that has 15 rt clocks, rt14 to rt0 are counted (decrement). during counting of rt8 to rt6, the uart receive control circuit samples the input pulses to the rxd0 pin to make a majority decision. the same level detected twice or more from among three samplings is processed as the data for the bit. the number of rt clocks can be changed in a range of 15 to 17 by setting uart0cr2. however, sampling is always executed in rt8 to rt6, even if the number of rt clocks is changed (figure 16-7). figure 16-7 data sampling in each case of uartcr2 tmp89ch42 page 229 ra001 rt15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 bit 0 start bit bit 0 start bit (b) uartcr2 is ?001b? rt clock internal received data rt15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 bit 0 start bit bit 0 start bit (a) uartcr2 is ?000b? rt clock rxd0 pin rxd0 pin rxd0 pin rxd0 pin rxd0 pin internal received data rt16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 16 bit 0 start bit bit 0 start bit (e) uartcr2 is ?100b? rt clock internal received data rt14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 14 13 12 11 bit 0 start bit bit 0 start bit (d) uartcr2 is ?011b? rt clock internal received data rt14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 14 13 12 11 10 bit 0 bit 1 bit 1 bit 1 bit 1 start bit bit 0 start bit (c) uartcr2 is ?010b? rt clock internal received data
if "1" is detected in sampling of the start bit, for example, due to the influence of noise, rt clock counting stops and the data receiving is suspended. subsequently, when a falling edge is detected in the input pulses to the rxd0 pin, rt clock counting restarts and the data receiving restarts with the start bit. figure 16-8 start bit sampling tmp89ch42 16. asynchronous serial interface (uart) 16.9 data sampling method page 230 ra001 rt15 14 13 12 11 10 9 8 7 6 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 bit 0 start bit start bit bit 0 rt clock rxd0 pin shift register noise bit 0 internal received data error because the start bit is 1 counting is suspended until the next falling edge is detected receiving continues because the start bit is 0 the received data is taken into the shift register a falling edge is detected a falling edge is detected
16.10 received data noise rejection when noise rejection is enabled at uart0cr2, the time of pulses to be regarded as signals is as shown in table 16-8. table 16-8 received data noise rejection time rxdnc noise rejection time [s] time of pulses to be regarded as signals 00 no noise rejection - 01 (uart0dr+1)/(transfer base clock frequency) 2 (uart0dr+1)/(transfer base clock frequency) 10 2 (uart0dr+1)/(transfer base clock frequency) 4 (uart0dr+1)/(transfer base clock frequency) 11 4 (uart0dr+1)/(transfer base clock frequency) 8 (uart0dr+1)/(transfer base clock frequency) note 1: the transfer base clock frequency is the clock frequency selected at uartcr1. figure 16-9 received data noise rejection tmp89ch42 page 231 ra001 receiving continues because the start bit is 0 the received data is taken into the shift register 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 7 6 5 4 3 bit 0 start bit start bit bit 0 rt clock internal received data shift register bit 0 rxd0 pin noise noise is removed a falling edge is detected when the noise rejection circuit is used
16.11 transmit/receive operation 16.11.1 data transmit operation set uart0cr1 to "1". check uart0sr = "0", and then write data into td0buf (transmit data buffer). writing data into td0buf sets uart0sr to "1", transfers the data to the transmit shift register, and outputs the data sequentially from the txd0 pin. the data output includes a start bit, stop bits whose number is specified in uart0cr1 and a parity bit if parity addition is specified. select the data transfer baud rate using uart0cr1, uart0cr2 and uart0dr. when data transmission starts, the transmit buffer full flag uart0sr is cleared to "0" and an inttxd0 interrupt request is generated. note 1: after data is written into td0buf, if new data is written into td0buf before the previous data is transferred to the shift register, the new data is written over the previous data and is transferred to the shift register. note 2: under the conditions shown in table 16-9, the txd0 pin output is fixed at the l or h level according to the setting of uart0cr1. table 16-9 txd0 pin output condition txd0 pin output irdasel="0" irdasel="1" when uart0cr1 is "0" h level l level from when "1" is written to uart0cr1 to when the trans- mitted data is written to td0buf when the stop, idle0 or sleep0 mode is active 16.11.2 data receive operation set uart0cr1 to "1". when data is received via the rxd0 pin, the received data is transferred to rd0buf (receive data buffer). at this time, the transmitted data includes a start bit, stop bit(s) and a parity bit if parity addition is specified. when the stop bit(s) are received, data only is extracted and transferred to rd0buf (receive data buffer). then the receive buffer full flag uart0sr is set and an intrxd0 interrupt request is generated. set the data transfer baud rate using uart0cr1, uart0cr2 and uart0dr. if an overrun error occurs when data is received, the data is not transferred to rd0buf (receive data buffer) but discarded; data in the rd0buf is not affected. tmp89ch42 16. asynchronous serial interface (uart) 16.11 transmit/receive operation page 232 ra001
16.12 status flag 16.12.1 parity error when the parity determined using the receive data bits differs from the received parity bit, the parity error flag uart0sr is set to "1". at this time, an intrxd0 interrupt request is generated. if uart0sr is "1" when uart0sr is read, uart0sr will be cleared to "0" when rd0buf is read subsequently. (the rd0buf read value becomes undefined.) if uart0sr is set to "1" after uart0sr is read, uart0sr will not be cleared to "0" when rd0buf is read subsequently. in this case, uart0sr will be cleared to "0" when uart0sr is read again and rd0buf is read. figure 16-10 occurrence of parity error tmp89ch42 page 233 ra001 rxd0 pin input indeterminate data reading perr is cleared to ?0? when rd0buf is read after reading perr=?1?. intrxd0 interrupt request uart0sr start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 parity stop reading of uart0sr reading of rd0buf rd0buf rxd0 pin input indeterminate not cleared data reading perr is cleared to ?0? when rd0buf is read after reading perr=?1?. intrxd0 interrupt request uart0sr start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 parity stop reading of uart0sr reading of rd0buf rd0buf data reading
16.12.2 framing error if the internal and external baud rates differ or "0" is sampled as the stop bit of received data due to the influence of noise on the rxd0 pin, the framing error flag uart0sr is set to "1". at this time, an intrxd0 interrupt request is generated. if uart0sr is "1" when uart0sr is read, uart0sr will be cleared to "0" when rd0buf is read subsequently. if uart0sr is set to "1" after uart0sr is read, uart0sr will not be cleared to "0" when rd0buf is read subsequently. in this case, uart0sr will be cleared to "0" when uart0sr is read again and rd0buf is read. figure 16-11 occurrence of framing error tmp89ch42 16. asynchronous serial interface (uart) 16.12 status flag page 234 ra001 rxd0 pin input a falling edge is detected ferr is generated if ?0? is received in the sampling of the stop bit. ferr is cleared to ?0? when rd0buf is read after reading ferr=?1?. ferr is cleared to ?0? when rd0buf is read after reading ferr=?1?. sampling intrxd0 interrupt request uart0sr when the external baud rate is slower than the internally set baud rate when the external baud rate is faster than the internally set baud rate start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 stop start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 stop reading of uart0sr reading of rd0buf rxd0 pin input a falling edge is detected a falling edge is detected ferr is generated if ?0? is received in the sampling of the stop bit. sampling intrxd0 interrupt request uart0sr start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 stop start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 stop start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 stop start bit0 bit1 bit2 bit3 bit4 bit5 reading of uart0sr reading of rd0buf rd0buf indeterminate data reading rd0buf indeterminate data reading
16.12.3 overrun error if receiving of all data bits is completed before the previous received data is read from rd0buf, the overrun error flag uart0sr is set to "1" and an intrxd0 interrupt request is generated. the data received at the occurrence of the overrun error is discarded and the previous received data is maintained. subsequently, if data is received while uart0sr is still "1", no intrxd0 interrupt request is generated, and the received data is discarded. (figure 16-12) note that parity or framing errors in the discarded received data cannot be detected. (these error flags are not set.) that is to say, if these errors are detected together with an overrun error during the reading of uart0sr, they have occurred in the previous received data (the data stored in rd0buf). (figure 16-13) if uart0sr is "1" when uart0sr is read, uart0sr will be cleared to "0" when rd0buf is read subsequently. (figure 16-14) if uart0sr is set to "1" after uart0sr is read, uart0sr will not be cleared to "0" when rd0buf is read subsequently. in this case, uart0sr will be cleared to "0" when uart0sr is read again and rd0buf is read. (figure 16-14) figure 16-12 generation of intrxd0 interrupt request tmp89ch42 page 235 ra001 rxd0 pin input data a data a an interrupt request is generated. the flag is set. an interrupt request is generated. no interrupt request is generated. data b intrxd0 interrupt request uart0sr uart0sr start bit0 bit1 bit7 stop start bit0 bit1 bit7 stop rd0buf start bit0 bit1 bit7 stop data c the contents of data b are discarded and those of data a are maintained. the contents of data c are discarded and those of data a are maintained.
figure 16-13 framing/parity error flags when an overrun error occurs tmp89ch42 16. asynchronous serial interface (uart) 16.12 status flag page 236 ra001 rxd0 pin input data a data a a parity error occurs. an interrupt request is generated. the error flag is not set together with an overrun error. an interrupt request is generated. the flag is set. no interrupt request is generated. data b intrxd0 interrupt request when a parity error occurs in the first received data and a framing error occurs in the second data when a parity error occurs in the second received data uart0sr uart0sr start bit0 parity stop start bit0 parity stop rd0buf uart0sr uart0sr start bit0 parity stop start bit0 parity stop data c data d the contents of data b are discarded and those of data a are maintained. the contents of data c are discarded and those of data a are maintained. the contents of data d are discarded and those of data a are maintained. the parity is ok. the parity is ok. the flag is not set even if a framing error occurs. rxd0 pin input data a data a an interrupt request is generated. an interrupt request is generated. no interrupt request is generated. data b intrxd0 interrupt request uart0sr uart0sr start bit0 parity stop start bit0 parity stop rd0buf uart0sr start bit0 parity stop start bit0 parity stop data c data d the contents of data b are discarded and those of data a are maintained. the contents of data c are discarded and those of data a are maintained. the contents of data d are discarded and those of data a are maintained. a parity error occurs.
figure 16-14 clearance of overrun error flag tmp89ch42 page 237 ra001 rxd0 pin input data a data a reading of data a the contents of data b are discarded and those of data a are maintained. data b oerr is cleared to ?0? when rd0buf is read after reading oerr=?1?. rbfl is cleared to ?0? when rd0buf is read after reading rbfl=?1?. intrxd0 interrupt request uart0sr uart0sr start bit0 bit1 bit7 stop start bit0 bit1 bit7 stop reading of uart0sr reading of rd0buf rd0buf rxd0 pin input data a data a reading of data a the contents of data b are discarded and those of data a are maintained. data b oerr is cleared to ?0? when rd0buf is read after reading oerr=?1?. rbfl is cleared to ?0? when rd0buf is read after reading rbfl=?1?. intrxd0 interrupt request uart0sr uart0sr start bit0 bit1 bit7 stop start bit0 bit1 bit7 stop reading of uart0sr reading of rd0buf rd0buf reading of data a
16.12.4 receive data buffer full loading the received data in rd0buf sets uart0sr to "1". if uart0sr is "1" when uart0sr is read, uart0sr will be cleared to "0" when rd0buf is read subsequently. if uart0sr is set to "1" after uart0sr is read, uart0sr will not be cleared to "0" when rd0buf is read subsequently. in this case, uart0sr will be cleared to "0" when uart0sr is read again and rd0buf is read. figure 16-15 occurrence of receive data buffer full tmp89ch42 16. asynchronous serial interface (uart) 16.12 status flag page 238 ra001 rxd0 pin input data a data a reading of data a data b reading of data b data b rbfl is cleared to ?0? when rd0buf is read after reading rbfl=?1?. intrxd0 interrupt request uart0sr start bit1 bit0 bit7 stop start bit0 bit1 bit7 stop reading of uart0sr reading of rd0buf rd0buf
16.12.5 transmit busy flag if transmission is completed with no waiting data in td0buf (when uart0sr="0"), uart0sr is cleared to "0". when transmission is restarted after data is written into td0buf, uart0sr is set to "1". at this time, an inttxd0 interrupt request is generated. figure 16-16 transmit busy flag and occurrence of transmit buffer full 16.12.6 transmit buffer full when td0buf has no data, or when data in td0buf is transferred to the transmit shift register and trans- mission is started, uart0sr is cleared to "0". at this time, an inttxd0 interrupt request is generated. writing data into td0buf sets uart0sr to "1". figure 16-17 occurrence of transmit buffer full tmp89ch42 page 239 ra001 txd0 pin input inttxd0 interrupt request uart0sr start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 stop start bit0 bit1 bit2 bit3 bit6 bit7 stop writing of td0buf uart0sr uart0cr1 data a data b writing of data a writing of data b txd0 pin input inttxd0 interrupt request uart0sr start bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 stop start bit0 bit1 bit6 bit7 stop writing of td0buf uart0sr uart0cr1 data a data b writing of data a writing of data b
16.13 receiving process figure 16-18 shows an example of the receiving process. details of flag judgments in the processing are shown in table 16-10 and table 16-11. if any framing error or parity error is detected, the received data has erroneous value(s). execute the error handling, for example, by discarding the received data read from rd0buf and receiving the data again. if any overrun error is detected, the receiving of one or more pieces of data is unfinished. it is impossible to determine the number of pieces of data that could not be received. execute the error handling, for example, by receiving data again from the beginning of the transfer. basically, an overrun error occurs when the internal software processing cannot follow the data transfer speed. it is recommended to slow the transfer baud rate or modify the software to execute flow control. figure 16-18 example of receiving process note 1: if multiple interrupts are used in the intrxd0 interrupt subroutine, the interrupt should be enabled after reading uart0sr and rd0buf. tmp89ch42 16. asynchronous serial interface (uart) 16.13 receiving process page 240 ra001 receiving process end when no receive interrupt is used when a receive interrupt is used read uart0sr read rd0buf error handling error handling error handling error handling data processing (received data is valid) uart0sr 1 1 1 0 0 0 1 0 uart0sr parity error framing error overrun error parity error framing error overrun error uart0sr uart0sr intrxd0 interrupt subroutine reti read uart0sr read rd0buf data processing (received data is valid) 1 1 0 0 1 0 uart0sr uart0sr uart0sr
table 16-10 flag judgments when no receive interrupt is used rbfl ferr/perr oerr state 0 - 0 data has not been received yet. 0 - 1 some pieces of data could not be received during the previous data receiving process ( receiving of next data is completed in the period from when uart0sr is read to when rd0buf is read in the previous data receiving process.) 1 0 0 receiving has been completed properly. 1 0 1 receiving has been completed properly, but some pieces of data could not be received. 1 1 0 received data has erroneous value(s). 1 1 1 received data has erroneous value(s) and some pieces of data could not be received. table 16-11 flag judgments when a receive interrupt is used ferr/perr oerr state 0 0 receiving has been completed properly. 0 1 receiving has been completed properly, but some pieces of data could not be received. 1 0 received data has erroneous value(s). 1 1 received data has erroneous value(s) and some pieces of data could not be received. tmp89ch42 page 241 ra001
16.14 ac properties 16.14.1 irda properties (v ss = 0 v, topr = ?40 to 85c) item condition min typ. max unit txd output pulse time (rt clock (3/16)) transfer baud rate = 2400 bps - 78.13 - s transfer baud rate = 9600 bps - 19.53 - transfer baud rate = 19200 bps - 9.77 - transfer baud rate = 38400 bps - 4.88 - transfer baud rate = 57600 bps - 3.26 - transfer baud rate = 115200 bps - 1.63 - tmp89ch42 16. asynchronous serial interface (uart) 16.14 ac properties page 242 ra001
16.15 revision history rev description ra001 revised table 16-6. "16.8.1.1 bit width adjustment using uart0cr2" changed example from fcgck=8mhz to fcgck=4mhz. "16.8.1.2 calculation of set values of uart0cr2 and uart0dr" changed example from fcgck=6mhz to fcgck=4mhz. "figure 16-6 example of uart0dr calculation" changed example from fcgck=6mhz to fcgck=4mhz. "figure 16-1 asynchronous serial interface (uart)" added ppga0 output to tca0 output. tmp89ch42 page 243 ra001
tmp89ch42 16. asynchronous serial interface (uart) 16.15 revision history page 244 ra001
17. synchronous serial interface (sio) the tmp89ch42 contains 1 channel of high-speed 8-bit serial interfaces of the clock synchronization type. table 17-1 sfr address assignment sioxcr (address) sioxsr (address) sioxbuf (address) serial interface 0 sio0cr (0x001f) sio0sr (0x0020) sio0buf (0x0021) table 17-2 pin names serial clock input/output pin serial data input pin serial data output pin serial interface 0 sclk0 pin si0 pin so0 pin tmp89ch42 page 245 ra001
17.1 configuration figure 17-1 serial interface note: the serial interface input/output pins are also used as the i/o ports. the i/o port register settings are required to use these pins for a serial interface. for details, refer to the chapter of i/o ports. tmp89ch42 17. synchronous serial interface (sio) 17.1 configuration page 246 ra001 shift register on transmitter shift register on receiver control circuit shift clock internal clock port (note) port (note) msb/lsb selection port (note) internal bus internal bus sio0cr sio0sr sio0buf sio0buf intsio0 interrupt request so0 pin si0 pin sclk0 pin
17.2 control the synchronous serial interface sio0 is controlled by the low power consumption registers (poffcr 2 ), the serial interface data buffer register (sio0buf), the serial interface control register (sio0cr) and the serial interface status register (sio0sr). low power consumption register 2 poffcr2 7 6 5 4 3 2 1 0 (0x0f76) bit symbol - - rtcen - - - - sio0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 rtcen rtc control 0 1 disable enable sio0en sio0 control 0 1 disable enable serial interface buffer register sio0buf 7 6 5 4 3 2 1 0 (0x0021) bit symbol sio0buf read/write r after reset 0 0 0 0 0 0 0 0 serial interface buffer register sio0buf 7 6 5 4 3 2 1 0 (0x0021) bit symbol sio0buf read/write w after reset 1 1 1 1 1 1 1 1 note 1: sio0buf is the data buffer for both transmission and reception. the last received data is read each time sio0buf is read. if sio0buf has never received data, it is read as "0". when data is written into it, the data is treated as the transmit data. tmp89ch42 page 247 ra001
serial interface control register sio0cr 7 6 5 4 3 2 1 0 (0x001f) bit symbol sioedg siocks siodir sios siom read/write r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 sioedg transfer edge selection 0 1 0: receive data at a rising edge and transmit data at a falling edge 1: transmit data at a rising edge and receive data at a falling edge siocks serial clock selection [hz] normal1/2 or idle1/2 mode slow1/2 or sleep1 mode 000 fcgck/2 9 - 001 fcgck/2 6 - 010 fcgck/2 5 - 011 fcgck/2 4 - 100 fcgck/2 3 - 101 fcgck/2 2 - 110 fcgck/2 fs/2 3 111 external clock input siodir transfer format (msb/lsb) selec- tion 0 1 lsb first (transfer from bit 0) msb first (transfer from bit 7) sios transfer operation start/stop in- struction 0 1 0: operation stop (reserved stop) 1: operation start siom transfer mode selection and operation 00 operation stop (forced stop) 01 8-bit transmit mode 10 8-bit receive mode 11 8-bit transmit and receive mode note 1: fcgck: gear clock [hz], fs: low-frequency clock [hz] note 2: after the operation is started by writing "1" to sios, writing to sioedg, siocks and siodir is invalid until sio0sr becomes "0". (sioedg, siocks and siodir can be changed at the same time as changing sios from "0" to "1".) note 3: after the operation is started by writing "1" to sios, no values other than"00" can be written to siom until siof becomes "0" (if a value from "01" to "11" is written to siom, it is ignored). the transfer mode cannot be changed during the operation. note 4: sios remains at "0", if "1" is written to sios when siom is "00" (operation stop). note 5: when sio is used in slow1/2 or sleep1 mode, be sure to set siocks to "110". if siocks is set to any other value, sio will not operate. when sio is used in slow1/2 or sleep1 mode, execute communications with siocks="110" in advance or change siocks after sio is stopped. note 6: when stop, idle0 or sleep0 mode is activated, siom is automatically cleared to "00" and sio stops the operation. at the same time, sios is cleared to "0". however, the values set for sioedg, siocks and siodir are maintained. tmp89ch42 17. synchronous serial interface (sio) 17.2 control page 248 ra001
serial interface status register sio0sr 7 6 5 4 3 2 1 0 (0x0020) bit symbol siof sef oerr rend uerr tbfl - - read/write r r r r r r r r after reset 0 0 0 0 0 0 0 0 siof serial transfer operation status monitor 0 1 transfer not in progress transfer in progress sef shift operation status monitor 0 1 shift operation not in progress shift operation in progress oerr receive overrun error flag 0 1 no overrun error has occurred at least one overrun error has occurred rend receive completion flag 0 1 no data has been received since the last receive data was read out at least one data receive operation has been executed uerr transmit underrun error flag 0 1 no transmit underrun error has occurred at least one transmit underrun error has occurred tbfl transmit buffer full flag 0 1 the transmit buffer is empty the transmit buffer has the data that has not yet been transmitted note 1: the oerr and uerr flags are cleared by reading sio0sr. note 2: the rend flag is cleared by reading sio0buf. note 3: writing "00" to sio0cr clears all the bits of sio0sr to "0", whether the serial interface is operating or not. when stop, idle0 or sleep0 mode is activated, siom is automatically cleared to "00" and all the bits of sio0sr are cleared to "0". note 4: bit 1 to 0 of sio0sr are read "0". tmp89ch42 page 249 ra001
17.3 low power consumption function serial interface 0 has the low power consumption registers (poffcr 2 ) that save power when the serial interface is not being used. setting poffcr2 to "0" disables the basic clock supply to serial interface 0 to save power. note that this renders the serial interface unusable. setting poffcr 2 to "1" enables the basic clock supply to serial interface 0 and allows the serial interface to operate. after reset, poffcr2 are initialized to "0", and this renders the serial interface unusable. when using the serial interface for the first time, be sure to set poffcr 2 to "1" in the initial setting of the program (before the serial interface control registers are operated). do not change poffcr2 to "0" during the serial interface operation. otherwise serial interface 0 may operate unexpectedly. tmp89ch42 17. synchronous serial interface (sio) 17.3 low power consumption function page 250 ra001
17.4 functions 17.4.1 transfer format the transfer format can be set to either msb or lsb first by using sio0cr. setting sio0cr to "0" selects lsb first as the transfer format. in this case, the serial data is transferred in sequence from the least significant bit. setting sio0cr to "1" selects msb first as the transfer format. in this case, the serial data is transferred in sequence from the most significant bit. 17.4.2 serial clock the serial clock can be selected by using sio0cr. setting sio0cr to "000" to "110" selects the internal clock as the serial clock. in this case, the serial clock is output from the sclk0 pin. the serial data is transferred in synchronization with the edge of the sclk0 pin output. setting sio0cr to "111" selects an external clock as the serial clock. in this case, an external serial clock must be input to the sclk0 pin. the serial data is transferred in synchronization with the edge of the external clock. the serial data transfer edge can be selected for both the external and internal clocks. for details, refer to "17.4.3 transfer edge selection". table 17-3 transfer baud rate sio0cr serial clock [hz] fcgck=4mhz fcgck=8mhz fcgck=10mhz fs=32.768khz normal1/2 or idle1/2 mode slow1/2 or sleep1 mode 1-bit time (s) baud rate (bps) 1-bit time (s) baud rate (bps) 1-bit time (s) baud rate (bps) 1-bit time (s) baud rate (bps) 000 fcgck/2 9 - 128 7.813k 64 15.625k 51.2 19.531k - - 001 fcgck/2 6 - 16 62.5k 8 125k 6.4 156.25k - - 010 fcgck/2 5 - 8 125k 4 250k 3.2 312.5k - - 011 fcgck/2 4 - 4 250k 2 500k 1.6 625k - - 100 fcgck/2 3 - 2 500k 1 1m 0.8 1.25m - - 101 fcgck/2 2 - 1 1m 0.5 2m 0.4 2.5m - - 110 fcgck/2 fs/2 3 0.5 2m 0.25 4m 0.2 5m 244 4k 17.4.3 transfer edge selection the serial data transfer edge can be selected by using siocr. table 17-4 transfer edge selection sio0cr data transmission data reception 0 falling edge rising edge 1 rising edge falling edge when siocr is "0", the data is transmitted in synchronization with the falling edge of the clock and the data is received in synchronization with the rising edge of the clock. when siocr is "1", the data is transmitted in synchronization with the rising edge of the clock and the data is received in synchronization with the falling edge of the clock. tmp89ch42 page 251 ra001
figure 17-2 transfer edge note: when an external clock input is used, 4/fcgck or longer is needed between the receive edge at the 8th bit and the transfer edge at the first bit of the next transfer. figure 17-3 interval time between bytes tmp89ch42 17. synchronous serial interface (sio) 17.4 functions page 252 ra001 c7 c6 d0 d1 d2 a7 a6 b0 b1 b2 tbi leading edge at the 1st bit (transmit edge) trailing edge at the 8th bit (receive edge) sclk0 pin so0 pin si0 pin symbol name minimum time tbi interval time between bytes 4/fcgck r1 r0 r2 r3 r4 r5 r6 r7 t1 t0 t2 t3 t4 t5 t6 t7 slck0 pin so0 pin si0 pin when siocr=?0? r1 r0 r2 r3 r4 r5 r6 r7 t1 t0 t2 t3 t4 t5 t6 t7 sclk0 pin so0 pin si0 pin when siocr=?1?
17.5 transfer modes 17.5.1 8-bit transmit mode the 8-bit transmit mode is selected by setting sio0cr to "01". 17.5.1.1 setting before starting the transmit operation, select the transfer edges at sio0cr, a transfer format at sio0cr and a serial clock at sio0cr. to use the internal clock as the serial clock, select an appropriate serial clock at sio0cr. to use an external clock as the serial clock, set sio0cr to "111". the 8-bit transmit mode is selected by setting sio0cr to "01". the transmit operation is started by writing the first byte of transmit data to sio0buf and then setting sio0cr to "1". writing data to sio0cr is invalid when the serial communication is in progress, or when sio0sr is "1". make these settings while the serial communication is stopped. while the serial communication is in progress (sio0sr="1"), only writing "00" to sio0cr or writing "0" to sio0cr is valid. 17.5.1.2 starting the transmit operation the transmit operation is started by writing data to sio0buf and then setting sio0cr to "1". the transmit data is transferred from sio0buf to the shift register, and then transmitted as the serial data from the so0 pin according to the settings of sio0cr. the serial data becomes undefined if the transmit operation is started without writing any transmit data to sio0buf. in the internal clock operation, the serial clock of the selected baud rate is output from the sclk0 pin. in the external clock operation, an external clock must be supplied to the sclk0 pin. by setting sio0cr to "1", sio0sr are automatically set to "1" and an intsio0 interrupt request is generated. sio0sr is cleared to "0" when the 8th bit of the serial data is output. 17.5.1.3 transmit buffer and shift operation if data is written to sio0buf when the serial communication is in progress and the shift register is empty, the written data is transferred to the shift register immediately. at this time, sio0sr remains at "0". if data is written to sio0buf when some data remains in the shift register, sio0sr is set to "1". if new data is written to sio0buf in this state, the contents of sio0buf are overwritten by the new value. make sure that sio0sr is "0" before writing data to sio0buf. 17.5.1.4 operation on completion of transmission the operation on completion of the data transmission varies depending on the operating clock and the state of sio0sr. (1) when the internal clock is used and sio0sr is "0" when the data transmission is completed, the sclk0 pin becomes the initial state and the so0 pin becomes the "h" level. sio0sr remains at "0". when the internal clock is used, the serial clock and data output is stopped until the next transmit data is written into sio0buf (automatic wait). tmp89ch42 page 253 ra001
when the subsequent data is written into sio0buf, sio0sr is set to "1", the sclk0 pin outputs the serial clock, and the transmit operation is restarted. an intsio0 interrupt request is gen- erated at the restart of the transmit operation. (2) when an external clock is used and sio0sr is "0" when the data transmission is completed, the so pin keeps last output value. when an external serial clock is input to the sclk0 pin after completion of the data transmission, an undefined value is trans- mitted and the transmit underrun error flag sio0sr is set to "1". if a transmit underrun error occurs, data must not be written to sio0buf during the transmission of an undefined value. (it is recommended to finish the transmit operation by setting sio0cr to "0" or force the transmit operation to stop by setting sio0cr to "00".) the transmit underrun error flag sio0sr is cleared by reading sio0sr. (3) when an internal or external clock is used and sio0sr is "1" when the data transmission is completed, sio0sr is cleared to "0". the data in sio0buf is transferred to the shift register and the transmission of subsequent data is started. at this time, sio0sr is set to "1" and an intsio0 interrupt request is generated. 17.5.1.5 stopping the transmit operation set sio0cr to "0" to stop the transmit operation. when sio0sr is "0", or when the shift operation is not in progress, the transmit operation is stopped immediately and an intsio0 interrupt request is generated. when sio0sr is "1", the transmit operation is stopped after all the data in the shift register is transmitted (reserved stop). at this time, an intsio0 interrupt request is generated again. when the transmit operation is completed, sio0sr are cleared to "0". other sio0sr registers keep their values. if the internal clock has been used, the so0 pin automatically returns to the "h" level. if an external clock has been used, the so0 pin keeps the last output value. to return the so0 pin to the "h" level, write "00" to sio0cr when the operation is stopped. the transmit operation can be forced to stop by setting sio0cr to "00" during the operation. by setting sio0cr to "00", sio0cr and sio0sr are cleared to "0" and the sio stops the operation, regardless of the sio0sr value. the so0 pin becomes the "h" level. if the internal clock is selected, the sclk0 pin returns to the initial level. tmp89ch42 17. synchronous serial interface (sio) 17.5 transfer modes page 254 ra001
figure 17-4 8-bit transmit mode (internal clock and reserved stop) figure 17-5 8-bit transmit mode (internal clock and forced stop) tmp89ch42 page 255 ra001 so0 pin (output) internal clock sclk0 pin (output) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 write to sio0buf sio0buf ab c d sio0cr sio0cr sio0sr sio0sr sio0sr data a data b writing data a writing data b writing data c writing data d forced stop start operation 01 01 00 00 start operation bit0 bit1 bit2 bit3 bit4 bit5 data c forced stop forced stop has priority over reserved stop data is not held but becomes the h level clock output is stopped reserved stop so0 pin (output) internal clock sclk0 pin (output) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 write to sio0buf sio0buf ab c sio0cr sio0cr sio0sr sio0sr sio0sr data a data b writing data a writing data b writing data c reserved stop start operation an interrupt is generated after transmission in case of reserved stop the level is held for the period of the internal clock(1/2) automatic wait 01 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data c
figure 17-6 8-bit transmit mode (external clock and reserved stop) figure 17-7 8-bit transmit mode (external clock and forced stop) tmp89ch42 17. synchronous serial interface (sio) 17.5 transfer modes page 256 ra001 so0 pin (output) sclk0 pin (input) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 write to sio0buf sio0buf abc d sio0cr sio0sr sio0sr sio0sr data a data c writing data a writing data b writing data c writing data d reserved stop start operation start operation bit0 bit1 bit2 bit3 bit4 bit5 data c forced stop forced stop has priority over reserved stop if two pieces of data are written, the latter data is effective when the operation is restarted after a forced stop, the last data written to the buffer is transmitted. data is not held but becomes the h level reserved stop sio0cr 01 01 00 00 so0 pin (output) sclk0 pin (input) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 write to sio0buf sio0buf ab c sio0cr sio0sr sio0sr sio0sr data a data b writing data a writing data b writing data c reserved stop start operation an interrupt is generated after transmission in case of reserved stop stopped while keeping the current level in the operation with an external clock returned to the h level by setting siocr1 to ?00? bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data c sio0cr 01 00
figure 17-8 8-bit transmit mode (external clock and occurrence of transmit underrun error) tmp89ch42 page 257 ra001 so0 pin (output) sclk0 pin (input) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 write to sio0buf sio0buf abc read sio0sr sio0cr sio0sr sio0sr sio0sr sio0sr data a data a data b writing data a writing data b reading sio0sr writing data c reserved stop start operation stopped while keeping the current level in the operation with an external clock returned to the h level by setting siocr1 to ?00? transferred to the buffer immediately after writing bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data b data c transferred to the buffer immediately after writing sio0cr 01 00
17.5.2 8-bit receive mode the 8-bit receive mode is selected by setting sio0cr to "10". 17.5.2.1 setting as in the case of the transmit mode, before starting the receive operation, select the transfer edges at sio0cr, a transfer format at sio0cr and a serial clock at sio0cr. to use the internal clock as the serial clock, select an appropriate serial clock at sio0cr. to use an external clock as the serial clock, set sio0cr to "111". the 8-bit receive mode is selected by setting sio0cr to "10". reception is started by setting sio0cr to "1". writing data to sio0cr is invalid when the serial communication is in progress, or when sio0sr is "1". make these settings while the serial communication is stopped. while the serial communication is in progress (sio0sr="1"), only writing "00" to sio0cr or writing "0" to sio0cr is valid. 17.5.2.2 starting the receive operation reception is started by setting sio0cr to "1". external serial data is taken into the shift register from the si0 pin according to the settings of sio0cr. in the internal clock operation, the serial clock of the selected baud rate is output from the sclk0 pin. in the external clock operation, an external clock must be supplied to the sclk0 pin. by setting sio0cr to "1", sio0sr are automatically set to "1". 17.5.2.3 operation on completion of reception when the data reception is completed, the data is transferred from the shift register to sio0buf and an intsio0 interrupt request is generated. the receive completion flag sio0sr is set to "1". in the operation with the internal clock, the serial clock output is stopped until the receive data is read from sio0buf (automatic wait). at this time, sio0sr is set to "0". by reading the receive data from sio0buf, sio0sr is set to "1", the serial clock output is restarted and the receive operation continues. in the operation with an external clock, data can be continuously received without reading the received data from sio0buf. in this case, data must be read from sio0buf before the subsequent data has been fully received. if the subsequent data is received completely before reading data from sio0buf, the overrun error flag sio0sr is set to "1". when an overrun error has occurred, set sio0cr to "00" to abort the receive operation. the data received at the occurrence of an overrun error is discarded, and sio0buf holds the data value received before the occurrence of the overrun error. sio0sr is cleared to "0" by reading data from sio0buf. sio0sr is cleared by reading sio0sr. 17.5.2.4 stopping the receive operation set sio0cr to "0" to stop the receive operation. when sio0sr is "0", or when the shift operation is not in progress, the operation is stopped immediately. unlike the transmit mode, no intsio0 interrupt request is generated in this state. when sio0sr is "1", the operation is stopped after the 8-bit data has been completely received (reserved stop). at this time, an intsio0 interrupt request is generated. tmp89ch42 17. synchronous serial interface (sio) 17.5 transfer modes page 258 ra001
after the operation has stopped completely, sio0sr are cleared to "0". other sio0sr registers keep their values. the receive operation can be forced to stop by setting sio0cr to "00" during the operation. by setting sio0cr to "00", sio0cr and sio0sr are cleared to "0" and the sio stops the operation, regardless of the sio0sr value. if the internal clock is selected, the sclk0 pin returns to the initial level. figure 17-9 8-bit receive mode (internal clock and reserved stop) tmp89ch42 page 259 ra001 si0 pin (input) internal clock sclk0 pin (output) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 read sio0buf sio0buf ac sio0cr sio0sr sio0sr sio0sr data a reading data a reading data c reserved stop automatic wait bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data c sio0cr 10
figure 17-10 8-bit receive mode (internal clock and forced stop) figure 17-11 8-bit receive mode (external clock and reserved stop) tmp89ch42 17. synchronous serial interface (sio) 17.5 transfer modes page 260 ra001 si0 pin (input) sclk0 pin (input) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 read sio0buf sio0buf abc sio0cr sio0sr sio0sr sio0sr data a reading data a reading data b reserved stop start operation bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data b bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data c sio0cr 10 si0 pin (input) internal clock sclk0 pin (output) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 read sio0buf sio0buf a sio0cr sio0cr sio0sr sio0sr sio0sr data a reading data a returned to the initial level reserved stop forced stop forced stop start operation start operation automatic wait 10 00 00 10 bit0 bit1 bit2 bit3 bit0 bit1 bit2 data b data c returned to the initial level
figure 17-12 8-bit receive mode (external clock and forced stop) figure 17-13 8-bit receive mode (external clock and occurrence of overrun error) tmp89ch42 page 261 ra001 si0 pin (input) sclk0 pin (input) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 read sio0buf sio0buf a read sio0sr sio0cr sio0cr sio0sr sio0sr sio0sr sio0sr data a reading data a data b is discarded subsequent data is received completely before reading data a data c is discarded reading sui0sr forced stop start operation 10 00 data b data c si0 pin (input) sclk0 pin (input) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 read sio0buf sio0buf ac sio0cr sio0cr sio0sr sio0sr sio0sr data a reading data a reading data c forced stop start operation start operation 10 00 10 data b data b is discarded data c
17.5.3 8-bit transmit/receive mode the 8-bit transmit/receive mode is selected by setting sio0cr to "11". 17.5.3.1 setting before starting the transmit/receive operation, select the transfer edges at sio0cr, a transfer format at sio0cr and a serial clock at sio0cr. to use the internal clock as the serial clock, select an appropriate serial clock at sio0cr. to use an external clock as the serial clock, set sio0cr to "111". the 8-bit transmit/receive mode is selected by setting sio0cr to "11". the transmit/receive operation is started by writing the first byte of transmit data to sio0buf and then setting sio0cr to "1". writing data to sio0cr is invalid when the serial communication is in progress, or when sio0sr is "1". make these settings while the serial communication is stopped. while the serial communication is in progress (sio0sr="1"), only writing "00" to sio0cr or writing "0" to siocr is valid. 17.5.3.2 starting the transmit/receive operation the transmit/receive operation is started by writing data to sio0buf and then setting sio0cr to "1". the transmit data is transferred from sio0buf to the shift register, and the serial data is transmitted from the so0 pin according to the settings of sio0cr. at the same time, the serial data is received from the si0 pin according to the settings of sio0cr. in the internal clock operation, the serial clock of the selected baud rate is output from the sclk0 pin. in the external clock operation, an external clock must be supplied to the sclk0 pin. the transmit data becomes undefined if the transmit/receive operation is started without writing any trans- mit data to sio0buf. by setting sio0cr to "1", sio0sr are automatically set to "1" and an intsio0 interrupt request is generated. sio0sr is cleared to "0" when the 8th bit of data is received. 17.5.3.3 transmit buffer and shift operation if any data is written to sio0buf when the serial communication is in progress and the shift register is empty, the written data is transferred to the shift register immediately. at this time, sio0sr remains at "0". if any data is written to sio0buf when some data remains in the shift register, sio0sr is set to "1". if new data is written to sio0buf in this state, the contents of sio0buf are overwritten by the new value. make sure that sio0sr is "0" before writing data to sio0buf. 17.5.3.4 operation on completion of transmission/reception when the data transmission/reception is completed, sio0sr is set to "1" and an intsio0 inter- rupt request is generated. the operation varies depending on the operating clock. tmp89ch42 17. synchronous serial interface (sio) 17.5 transfer modes page 262 ra001
(1) when the internal clock is used if sio0sr is "1", it is cleared to "0" and the transmit/receive operation continues. if sio0sr is already "1", sio0sr is set to "1". if sio0sr is "0", the transmit/receive operation is aborted. the sclk0 pin becomes the initial state and the so0 pin becomes the "h" level. sio0sr remains at "0". when the subsequent data is written to sio0buf, sio0sr is set to "1", the sclk0 pin outputs the clock and the transmit/receive operation is restarted. to confirm the receive data, read it from sio0buf before writing data to sio0buf. (2) when an external clock is used the transmit/receive operation continues. if the external serial clock is input without writing any data to sio0buf, the last data value set to sio0buf is re-transmitted. at this time, the transmit underrun error flag sio0sr is set to "1". when the next 8-bit data is received completely before sio0buf is read, or in the state of sio0sr="1", sio0sr is set to "1". 17.5.3.5 stopping the transmit/receive operation set sio0cr to "0" to stop the transmit/receive operation. when sio0sr is "0", or when the shift operation is not in progress, the operation is stopped immediately. unlike the transmit mode, no intsio0 interrupt request is generated in this state. when sio0sr is "1", the operation is stopped after the 8-bit data is received completely. at this time, an intsio0 interrupt request is generated. after the operation has stopped completely, sio0sr are cleared to "0". other sio0sr registers keep their values. if the internal clock has been used, the so0 pin automatically returns to the "h" level. if an external clock has been used, the so0 pin keeps the last output value. to return the so0 pin to the "h" level, write "00" to sio0cr when the operation is stopped. the transmit/receive operation can be forced to stop by setting sio0cr to "00" during the oper- ation. by setting sio0cr to "00", sio0cr and sio0sr are cleared to "0" and the sio stops the operation, regardless of the sio0sr value. the so0 pin becomes the "h" level. if the internal clock is selected, the sclk0 pin returns to the initial level. tmp89ch42 page 263 ra001
figure 17-14 8-bit transmit/receive mode (internal clock and reserved stop) tmp89ch42 17. synchronous serial interface (sio) 17.5 transfer modes page 264 ra001 si0 pin (input) internal clock sclk0 pin (output) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 write to sio0buf sio0buf (write buffer) de fg sio0buf (read buffer) ab c sio0cr sio0sr sio0sr sio0sr sio0sr data a data b writing data d read sio0buf reading data a reading data b reading data c writing data e writing data f writing data g reserved stop start operation wait bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data c so0 pin (output) bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data d data e bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data f
figure 17-15 8-bit transmit/receive mode (external clock and reserved stop) tmp89ch42 page 265 ra001 si0 pin (input) sclk0 pin (input) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 write to sio0buf sio0buf (write buffer) de fg sio0buf (read buffer) ab c sio0cr sio0cr sio0sr sio0sr sio0sr sio0sr data a 11 00 data b writing data d read sio0buf reading data a reading data b reading data c writing data e writing data f writing data g reserved stop start operation bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data c so0 pin (output) bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data d data e bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data f
figure 17-16 8-bit transmit/receive mode (external clock, occurrence of transmit underrun error and occurrence of overrun error) tmp89ch42 17. synchronous serial interface (sio) 17.5 transfer modes page 266 ra001 si0 pin (input) sclk0 pin (input) intsio0 interrupt request bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 write to sio0buf sio0buf (write buffer) dfg sio0buf (read buffer) ac read sio0sr sio0cr sio0sr sio0sr sio0sr sio0sr sio0sr sio0sr data a data b writing data d read sio0buf reading data a reading data c writing data f writing data g reserved stop start operation bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data c so0 pin (output) bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data d data d data f bit0 bit1 bit2 bit3 bit4 bit5 bit6 bit7 data g
17.6 ac characteristics figure 17-17 ac characteristics (v ss = 0 v, v dd = 4.5 v - 5.5 v, topr = -40 to 85c) parameter symbol condition min typ. max unit sclk cycle time t scy internal clock operation so pin and sclk pin load capacity=100 pf 2 / fcgck - - ns sclk "l" pulse width t scyl 1 / fcgck ? 25 - - sclk "h" pulse width t scyh 1 / fcgck ? 15 - - si input setup time t sis 60 - - si input hold time t sih 35 - - so output delay time t sod ?50 - 50 sclk cycle time t scy external clock operation so pin and sclk pin load capacity=100 pf 2 / fcgck - - sclk "l" pulse width t scyl 1 / fcgck - - sclk "h" pulse width t scyh 1 / fcgck - - si input setup time t sis 50 - - si input hold time t sih 50 - - so output delay time t sod 0 - 60 sclk low-level input voltage t sclkl 0 - v dd 0.30 v sclk high-level input voltage t sclkh v dd 0.70 - v dd figure 17-18 interval time between bytes tmp89ch42 page 267 ra001 c7 c6 d0 d1 d2 a7 a6 b0 b1 b2 tbi leading edge at the 1st bit (transmit edge) trailing edge at the 8th bit (receive edge) sclk0 pin so0 pin si0 pin symbol name minimum time tbi interval time between bytes 4/fcgck sclk pin t sis v sclkl v sclkh t scyl t scyh t scy t sod t sih si pin so pin
17.7 revision history rev description ra001 "table 17-3 transfer baud rate" revised table (add some fcgck condition). "17.6 ac characteristics" revised table (add some fcgck condition). tmp89ch42 17. synchronous serial interface (sio) 17.7 revision history page 268 ra001
18. serial bus interface (sbi) the tmp89ch42 contains 1 channels of serial bus interface (sbi). the serial bus interface supports serial communication conforming to the i 2 c bus standards. it has clock synchro- nization and arbitration functions, and supports the multi-master in which multiple masters are connected on a bus. it also supports the unique free data format. tmp89ch42 page 269 ra002
18.1 communication format 18.1.1 i 2 c bus the i 2 c bus is connected to devices via the sda0 and scl0 pins and can communicate with multiple devices. figure 18-1 device connections communications are implemented between a master and slave. the master transmits the start condition, the slave addresses, the direction bit and the stop condition to the slave(s) connected to the bus, and transmits and receives data. the slave detects these conditions transmitted from the master by the hardware, and transmits and receives data. the data format of the i 2 c bus that can communicate via the serial bus interface is shown in figure 18-2. the serial bus interface does not support the following functions among those specified by the i 2 c bus stand- ards: 1. start byte 2. 10-bit addressing 3. sda and scl pins falling edge slope control tmp89ch42 18. serial bus interface (sbi) 18.1 communication format page 270 ra002 vdd device 1 sda scl device 2 sda scl device n sda scl
figure 18-2 data format of i 2 c bus 18.1.2 free data format the free data format is for communication between a master and slave. in the free data format, the slave address and the direction bit are processed as data. figure 18-3 free data format tmp89ch42 page 271 ra002 8 bits 1 1 or more 1 to 8 bits 1 1 s a c k a c k a c k p data data data 1 to 8 bits 1 (a) free data format s r/w ack p : start condition : direction bit : acknowledge bit : stop condition 8 bits 1 1 or more 1 to 8 bits 1 1 s a c k a c k a c k p slave address data data 1 to 8 bits 1 r / w 8 bits 1 1 1 or more 1 or more 1 to 8 bits 1 1 1 s a c k a c k a c k p slave address data data slave address 1 to 8 bits 1 r / w 8 bits a c k r / w s (a) addressing format (b) addressing format (with restart) s r/w ack p : start condition : direction bit : acknowledge bit : stop condition
18.2 configuration figure 18-4 serial bus interface 0 (sbi0) tmp89ch42 18. serial bus interface (sbi) 18.2 configuration page 272 ra002 sbi0cr1 i2c0ar sbi0dbr sbi0cr2 sbi0sr2 clock control circuit software reset circuit transfer control circuit shift register data control circuit l o r t n o c t u p t u o / t u p n i sda scl noise canceller noise canceller c b t s r w s n i p / b b / x r t / t s m k c a k c a o n k c s s l a b r l 0 s a / s a a / l a / x r t / t s m b b a s intsbi interrupt request
18.3 control the following registers are used to control the serial bus interface and monitor the operation status. ? serial bus interface control register 1 (sbi0cr1) ? serial bus interface control register 2 (sbi0cr2) ? serial bus interface status register 2 (sbi0sr2) ? serial bus interface data buffer register (sbi0dbr) ? i 2 c bus address register (i2c0ar) in addition, the serial bus interface has low power consumption registers that save power when the serial bus interface is not being used. low power consumption register 1 poffcr1 7 6 5 4 3 2 1 0 (0x0f75) bit symbol - - - sbi0en - - uart1en uart0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 sbi0en i2c0 control 0 1 disable enable uart1en uart1 control 0 1 disable enable uart0en uart0 control 0 1 disable enable note 1: when sbi0en is cleared to "0", the clock supply to the serial bus interface is stopped. at this time, the data written to the serial bus interface control registers is invalid. when the serial bus interface is used, set sbi0en to "1" and then write the data to the serial bus interface control registers. tmp89ch42 page 273 ra002
serial bus interface control register 1 sbi0cr1 (0x0022) 7 6 5 4 3 2 1 0 bit symbol bc ack noack sck read/write r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 note 1: fcgck: gear clock [hz], fs: low-frequency clock oscillation circuit clock note 2: don't change the contents of the registers when the start condition is generated, the stop condition is generated or the data transfer is in progress. write data to the registers before the start condition is generated or during the period from when an interrupt request is generated for stopping the data transfer until it is released. note 3: after a software reset is generated, all the bits of sbi0cr2 register except sbi0cr2 and the sbi0cr1, i2c0ar and sbi0sr2 registers are initialized. note 4: when the operation is switched to stop, idle0 or slow mode, the sbi0cr2 register, except sbi0cr2, and the sbi0cr1, i2c0ar and sbi0dbr registers are initialized. note 5: when fcgck is 4mhz, sck should be not set to 0y000, 0y001 or 0y010 because it is not possible to satisfy the bus specification of fast mode. serial bus interface control register 2 sbi0cr2 (0x0023) 7 6 5 4 3 2 1 0 bit symbol mst trx bb pin sbim - swrst read/write w w w w w r w after reset 0 0 0 1 0 0 0 note 1: when sbi0cr2 is "0", no value can be written to sbi0cr2 except sbi0cr2. before writing values to sbi0cr2, write "1" to sbi0cr2 to activate the serial bus interface mode. note 2: don't change the contents of the registers, except sbi0cr2, when the start condition is generated, the stop condition is generated or the data transfer is in progress. write data to the registers before the start condition is generated or during the period from when an interrupt request is generated for stopping the data transfer until it is released. note 3: make sure that the port is in a high state before switching the port mode to the serial bus interface mode. make sure that the bus is free before switching the serial bus interface mode to the port mode. note 4: sbi0cr2 is a write-only register, and must not be accessed by using a read-modify-write instruction, such as a bit oper- ation. note 5: after a software reset is generated, all the bits of sbi0cr2 register except sbi0cr2 and the sbi0cr1, i2c0ar and sbi0sr2 registers are initialized. note 6: when the operation is switched to stop, idle0 or slow mode, the sbi0cr2 register, except sbi0cr2, and the sbi0cr1, i2c0ar and sbi0dbr registers are initialized. serial bus interface status register 2 sbi0sr2 (0x0023) 7 6 5 4 3 2 1 0 bit symbol mst trx bb pin al aas ad0 lrb read/write r r r r r r r r after reset 0 0 0 1 0 0 0 * note 1: * : unstable note 2: when sbi0cr2 becomes "0", sbi0sr is initialized. note 3: after a software reset is generated, all the bits of the sbi0cr2 register except sbi0cr2 and the sbi0cr1, i2c0ar and sbi0sr2 registers are initialized. note 4: when the operation is switched to stop, idle0 or slow mode, the sbi0cr2 register, except sbi0cr2, and the sbi0cr1, i2c0ar and sbi0dbr registers are initialized. tmp89ch42 18. serial bus interface (sbi) 18.3 control page 274 ra002
i 2 c bus address register i2c0ar (0x0024) 7 6 5 4 3 2 1 0 bit symbol sa als read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 note 1: don't set i2c0ar to "0x00". if it is set to "0x00", the slave address is deemed to be matched when the i 2 c bus standard start byte ("0x01") is received in the slave mode. note 2: don't change the contents of the registers when the start condition is generated, the stop condition is generated or the data transfer is in progress. write data to the registers before the start condition is generated or during the period from when an interrupt request is generated for stopping the data transfer until it is released. note 3: after a software reset is generated, all the bits of the sbi0cr2 register except sbi0cr2 and the sbi0cr1, i2c0ar and sbi0sr2 registers are initialized. note 4: when the operation is switched to stop, idle0 or slow mode, the sbi0cr2 register, except sbi0cr2, and the sbi0cr1, i2c0ar and sbi0dbr registers are initialized. serial bus interface data buffer register sbi0dbr (0x0025) 7 6 5 4 3 2 1 0 bit symbol sbi0dbr read/write r/w after reset 0 0 0 0 0 0 0 0 note 1: write the transmit data beginning with the most significant bit (bit 7). note 2: sbi0dbr has individual writing and reading buffers, and written data cannot be read out. therefore, sbi0dbr must not be accessed by using a read-modify-write instruction, such as a bit operation. note 3: don't change the contents of the registers when the start condition is generated, the stop condition is generated or the data transfer is in progress. write data to the registers before the start condition is generated or during the period from when an interrupt request is generated for stopping the data transfer until it is released. note 4: to set sbi0cr2 to "1" by writing the dummy data to sbi0dbr, write 0x00. writing any data other than 0x00 causes an improper value in the subsequently received data. note 5: when the operation is switched to stop, idle0 or slow mode, the sbi0cr2 register, except sbi0cr2, and the sbi0cr1, i2c0ar and sbi0dbr registers are initialized. tmp89ch42 page 275 ra002
18.4 functions 18.4.1 low power consumption function the serial bus interface has a low power consumption register (poffcr1) that saves power when the serial bus interface is not being used. setting poffcr1 to "0" disables the basic clock supply to the serial bus interface to save power. note that this makes the serial bus interface unusable. setting poffcr1 to "1" enables the basic clock supply to the serial bus interface and makes external interrupts usable. after reset, poffcr1 is initialized to "0", and this makes the serial bus interface unusable. when using the serial bus interface for the first time, be sure to set poffcr1 to "1" in the initial setting of the program (before the serial bus interface control registers are operated). do not change poffcr1 to "0" during the serial bus interface operation, otherwise serial bus interface may operate unexpectedly. 18.4.2 selecting the slave address match detection and the general call detection sbi0cr1 enables and disables the slave address match detection and the general call de- tection in the slave mode. clearing sbi0cr1 to "0" enables the slave address match detection and the general call detection. setting sbi0cr1 to "1" disables the subsequent slave address match and general call de- tections. the slave addresses and "general call" sent from the master are ignored. no acknowledgement is returned and no interrupt request is generated. in the master mode, sbi0cr1 is ignored and has no influence on the operation. note: if sbi0cr1 is cleared to "0" during data transfer in the slave mode, it remains at "1" and returns an acknowledge signal of data transfer. 18.4.3 selecting the number of clocks for data transfer and selecting the acknowledge- ment or non-acknowledgment mode 1-word data transfer consists of data and an acknowledge signal. when the data transfer is finished, an interrupt request is generated. sbi0cr1 is used to select the number of bits of data to be transmitted/received subsequently. the acknowledgment mode is activated by setting sbi0cr1 to "1". the master device generates the clocks for an acknowledge signal and outputs an acknowledge signal in the receiver mode. the slave device counts the clocks for an acknowledge signal and outputs an acknowledge signal in the receiver mode. the non-acknowledgment mode is activated by setting sbi0cr1 to "0". the master device does not generate the clocks for an acknowledge signal. the slave device does not count the clocks for an acknowledge signal. 18.4.3.1 number of clocks for data transfer the number of clocks for data transfer is set by using sbi0cr1 and sbi0cr1. the acknowledgment mode is activated by setting sbi0cr1 to "1". tmp89ch42 18. serial bus interface (sbi) 18.4 functions page 276 ra002
in the acknowledgment mode, the master device generates the clocks that correspond to the number of data bits, generates the clocks for an acknowledge signal, and generates an interrupt request. the slave device counts the clocks that correspond to the data bits, counts the clocks for an acknowledge signal, and generates an interrupt request. the non-acknowledgment mode is activated by setting sbi0cr1 to "0". in the non-acknowledgment mode, the master device generates the clocks that correspond to the number of data bits, and generates an interrupt request. the slave device counts the clocks that correspond to the data bits, and generates an interrupt request. figure 18-5 number of clocks for data transfer and sbi0cr1 and sbi0cr1 the relationship between the number of clocks for data transfer and sbi0cr1 and sbi0cr1 is shown in table 18-1. table 18-1 relationship between the number of clocks for data transfer and sbi0cr1 and sbi0cr1 bc ack=0 (non-acknowledgment mode) ack=1 (acknowledgment mode) number of clocks for data transfer number of data bits number of clocks for data transfer number of data bits 000 8 8 9 8 001 1 1 2 1 010 2 2 3 2 011 3 3 4 3 100 4 4 5 4 101 5 5 6 5 110 6 6 7 6 111 7 7 8 7 bc is cleared to "000" by the start condition. therefore, the slave address and the direction bit are always transferred in 8-bit units. in other cases, bc keeps the set value. note: sbi0cr1 must be set before transmitting or receiving a slave address. when sbi0cr1 is cleared, the slave address match detection and the direction bit detection are not executed properly. 18.4.3.2 output of an acknowledge signal in the acknowledgment mode, the sda0 pin changes as follows during the period of the clocks for an acknowledge signal. ? in the master mode tmp89ch42 page 277 ra002 22 33 44 56 11 sbi0cr1="110", sbi0cr1="0" intsbi0 interrupt request sbi0cr1="011", sbi0cr1="1"
in the transmitter mode, the sda0 pin is released to receive an acknowledge signal from the receiver during the period of the clocks for an acknowledge signal. in the receiver mode, the sda0 pin is pulled down to the low level and an acknowledge signal is generated during the period of the clocks for an acknowledge signal. ? in the slave mode when a match between the received slave address and the slave address set to i2c0ar is detected or when a general call is received, the sda0 pin is pulled down to the low level and an acknowledge signal is generated during the period of the clocks for an acknowledge signal. during the data transfer after the slave address match is detected or a "general call" is received in the transmitter mode, the sda0 pin is released to receive an acknowledge signal from the receiver during the period of the clocks for an acknowledge signal. in the receiver mode, the sda0 pin is pulled down to the low level and an acknowledge signal is generated. table 18-2 shows the states of the scl0 and sda0 pins in the acknowledgment mode. note: in the non-acknowledgment mode, the clocks for an acknowledge signal are not generated or counted, and thus no acknowledge signal is output. table 18-2 states of the scl0 and sda0 pins in the acknowledgment mode mode pin condition transmitter receiver master scl0 - add the clocks for an acknowl- edge signal. add the clocks for an acknowl- edge signal sda0 - release the pin to receive an acknowledge signal output the low level as an ac- knowledge signal to the pin slave scl0 - count the clocks for an ac- knowledge signal count the clocks for an ac- knowledge signal sda0 when the slave address match is detected or a "general call" is re- ceived - output the low level as an ac- knowledge signal to the pin during transfer after the slave address match is detected or a "general call" is received release the pin to receive an acknowledge signal output the low level as an ac- knowledge signal to the pin 18.4.4 serial clock 18.4.4.1 clock source sbi0cr1 is used to set the high and low periods of the serial clock to be output in the master mode. sck t high (m/fcgck) t low (n/fcgck) m n 000: 9 12 001: 11 14 010: 15 18 011: 23 26 100: 39 42 101: 71 74 110: 135 138 111: 263 266 tmp89ch42 18. serial bus interface (sbi) 18.4 functions page 278 ra002
figure 18-6 scl output note: there are cases where the high period differs from t high selected at sbi0cr1 when the rising edge of the scl pin becomes blunt due to the load capacity of the bus. in the master mode, the hold time when the start condition is generated is t high [s] and the setup time when the stop condition is generated is t high [s]. when sbi0cr2 is set to "1" in the slave mode, the time that elapses before the release of the scl pin is t low [s]. in both the master and slave modes, the high level period must be 3/fcgck[s] or longer and the low level period must be 5/fcgck[s] or longer for the externally input clock, regardless of the sbi0cr1 setting. figure 18-7 scl input 18.4.4.2 clock synchronization in the i 2 c bus, due to the structure of the pin, in order to drive a bus with a wired and, a master device which pulls down a clock pulse to low will, in the first place, invalidate the clock pulse of another master device which generates a high-level clock pulse. therefore, the master outputting the high level must detect this to correspond to it. the serial bus interface circuit has a clock synchronization function. this function ensures normal transfer even if there are two or more masters on the same bus. the example explains clock synchronization procedures when two masters simultaneously exist on a bus. figure 18-8 example of clock synchronization tmp89ch42 page 279 ra002 count start abc scl pin (master 1) scl pin (master 2) scl (bus) count reset wait count reset scl input t low t high t high 3 / fcgck t low 5 / fcgck 1/fscl t low t high scl output t high = m / fcgck t low = n / fcgck fscl = 1 / (t high + t low )
as master 1 pulls down the scl pin to the low level at point "a", the scl line of the bus becomes the low level. after detecting this situation, master 2 resets counting a clock pulse in the high level and sets the scl pin to the low level. master 1 finishes counting a clock pulse in the low level at point "b" and sets the scl pin to the high level. since master 2 holds the scl line of the bus at the low level, master 1 waits for counting a clock pulse in the high level. after master 2 sets a clock pulse to the high level at point "c" and detects the scl line of the bus at the high level, master 1 starts counting a clock pulse in the high level. then, the master, which has finished the counting a clock pulse in the high level, pulls down the scl pin to the low level. the clock pulse on the bus is determined by the master device with the shortest high-level period and the master device with the longest low-level period from among those master devices connected to the bus. 18.4.5 master/slave selection to set a master device, sbi0cr2 should be set to "1". to set a slave device, sbi0cr2 should be cleared to "0". when a stop condition on the bus or an arbitration lost is detected, sbi0cr2 is cleared to "0" by the hardware. 18.4.6 transmitter/receiver selection to set the device as a transmitter, sbi0cr2 should be set to "1". to set the device as a receiver, sbi0cr2 should be cleared to "0". for the i 2 c bus data transfer in the slave mode, sbi0cr2 is set to "1" by the hardware if the direction bit (r/ w) sent from the master device is "1", and is cleared to "0" if the bit is "0". in the master mode, after an acknowledge signal is returned from the slave device, sbi0cr2 is cleared to "0" by hardware if a transmitted direction bit is "1", and is set to "1" by hardware if it is "0". when an acknowledge signal is not returned, the current condition is maintained. when a stop condition on the bus or an arbitration lost is detected, sbi0cr2 is cleared to "0" by the hardware. table 18-3 shows sbi0cr2 changing conditions in each mode and sbi0cr2 value after changing. note: when sbi0cr1 is "1", the slave address match detection and the general call detection are disabled, and thus sbi0cr2 remains unchanged. table 18-3 sbi0cr1 operation in each mode mode direction bit changing condition trx after changing slave mode "0" a received slave address is the same as the value set to i2c0ar "0" "1" "1" master mode "0" ack signal is returned "1" "1" "0" when the serial bus interface circuit operates in the free data format, a slave address and a direction bit are not recognized. they are handled as data just after generating the start condition. sbi0cr2 is not changed by the hardware. 18.4.7 start/stop condition generation when sbi0sr2 is "0", a slave address and a direction bit which are set to the sbi0dbr are output on a bus after generating a start condition by writing "1" to sbi0cr2 , sbi0cr2, sbi0cr2 and sbi0cr2. it is necessary to set sbi0cr1 to "1" before generating the start condition. tmp89ch42 18. serial bus interface (sbi) 18.4 functions page 280 ra002
figure 18-9 generating the start condition and a slave address when sbi0cr2 is "1", the sequence of generating the stop condition on the bus is started by writing "1" to sbi0cr2, sbi0cr2 and sbi0cr2 and writing "0" to sbi0cr2. when a stop condition is generated. the scl line on a bus is pulled down to the low level by another device, a stop condition is generated after releasing the scl line. figure 18-10 stop condition generation the bus condition can be indicated by reading the contents of sbi0sr2. sbi0sr2 is set to "1" when the start condition on the bus is detected (bus busy state) and is cleared to "0" when the stop condition is detected (bus free state). 18.4.8 interrupt service request and release when a serial bus interface circuit is in the master mode and transferring a number of clocks set by sbi0cr1 and sbi0cr1 is complete, a serial bus interface interrupt request (intsbi0) is generated. in the slave mode, a serial bus interface interrupt request (intsbi0) is generated when the above and following conditions are satisfied: ? at the end of the acknowledge signal when the received slave address matches to the value set by the i2c0ar with sbi0cr1 set at "0" ? at the end of the acknowledge signal when a "general call" is received with sbi0cr1 set at "0" ? at the end of transferring or receiving after matching of the slave address or receiving of "general call" when a serial bus interface interrupt request occurs, sbi0cr2 is cleared to "0". during the time that sbi0cr2 is "0", the scl0 pin is pulled down to the low level. tmp89ch42 page 281 ra002 stop condition scl0 pin sda0 pin slave address and direction bit start condition acknowledge signal 23456789 a3 a2 a1 a0 a4 a5 a6 r/w 1 scl0 pin sda0 pin intsbi0 interrupt request
figure 18-11 sbi0cr2 and scl0 pin writing data to sbi0dbr sets sbi0cr2 to "1". the time from sbi0cr2 being set to "1" until the sbi0 pin is released takes t low . although sbi0cr2 can be set to "1" by the software, sbi0cr2 can not be cleared to "0" by the software. 18.4.9 setting of serial bus interface mode sbi0cr2 is used to set serial bus interface mode. setting sbi0cr2 to "1" selects the serial bus interface mode. setting it to "0" selects the port mode. set sbi0cr2 to "1" in order to set serial bus interface mode. before setting of serial bus interface mode, confirm serial bus interface pins in a high level, and then, write "1" to sbi0cr2. and switch a port mode after confirming that a bus is free and set sbi0cr2 to "0". note: when sbi0cr2 is "0", no data can be written to sbi0cr2 except sbi0cr2. before setting values to sbi0cr2, write "1" to sbi0cr2 to activate the serial bus interface mode. 18.4.10 software reset the serial bus interface circuit has a software reset function that initializes the serial bus interface circuit. if the serial bus interface circuit locks up, for example, due to noise, it can be initialized by using this function. a software reset is generated by writing "10" and then "01" to sbi0cr2. after a software reset is generated, the serial bus interface circuit is initialized and all the bits of sbi0cr2 register, except sbi0cr2 and the sbi0cr1, i2c0ar and sbi0sr2 registers, are initialized. 18.4.11 arbitration lost detection monitor since more than one master device can exist simultaneously on a bus, a bus arbitration procedure is imple- mented in order to guarantee the contents of transferred data. data on the sda line is used for bus arbitration of the i 2 c bus. the following shows an example of a bus arbitration procedure when two master devices exist simultaneously on a bus. master 1 and master 2 output the same data until point "a". after that, when master 1 outputs "1" and master 2 outputs "0", since the sda line of a bus is wired and, the sda line is pulled down to the low level by master 2. when the scl line of a bus is pulled-up at point "b", the slave device reads data on the sda line, that is data in master 2. data transmitted from master 1 becomes invalid. the state in master 1 is called "arbitration tmp89ch42 18. serial bus interface (sbi) 18.4 functions page 282 ra002 23 789 1 1 t low scl0 pin scl0 pin is pulled to low when sbi0cr2 is "0" set sbi0cr2 to "1" or write data to sbi0dbr sbi0cr2 intsbi0 interrupt request
lost". a master device which loses arbitration releases the sda pin and the scl pin in order not to effect data transmitted from other masters with arbitration. when more than one master sends the same data at the first word, arbitration occurs continuously after the second word. figure 18-12 arbitration lost the serial bus interface circuit compares levels of a sda line of a bus with its sda pin at the rising edge of the scl line. if the levels are unmatched, arbitration is lost and sbi0sr2 is set to "1". when sbi0sr2 is set to "1", sbi0cr2 and sbi0cr2 are cleared to "0" and the mode is switched to a slave receiver mode. thus, the serial bus interface circuit stops output of clock pulses during data transfer after the sbi0sr2 is set to "1". after the data transfer is completed, sbicr2 is cleared to "0" and the scl pin is pulled down to the low level. sbi0sr2 is cleared to "0" by writing data to the sbi0dbr, reading data from the sbi0dbr or writing data to the sbi0cr2. figure 18-13 example when master b is a serial bus interface circuit tmp89ch42 page 283 ra002 scl pin sda pin scl pin sda pin sbi0sr2 sbi0cr2 sbi0cr2 sbi0cr2 intsbi0 interrupt request a ccess to sbi0dbr or sbi0cr2 d4a 123 123 456789 12 3456789 master a master b stop clock output releasing sda pin and scl pin to high level as losing arbitration. d5a d6a d7a d3a d2a d1a d0a d6a d7a d5a? d6a? d7a? ab scl (bus) sda pin (master 1) sda pin (master 2) sda (bus) the sda pin becomes "1" after losing arbitration.
18.4.12 slave address match detection monitor in the slave mode, sbi0sr2 is set to "1" when the received data is "general call" or the received data matches the slave address setting by i2c0ar with sbi0cr1 set at "0" and the i 2 c bus mode is active (i2c0ar="0"). setting sbi0cr1 to "1" disables the subsequent slave address match and general call de- tections. sbi0sr2 remains at "0" even if a "general call" is received or the same slave address as the i2c0ar set value is received. when a serial bus interface circuit operates in the free data format (i2c0ar= "1"), sbi0sr2 is set to "1" after receiving the first 1-word of data. sbi0sr2 is cleared to "0" by writing data to the sbi0dbr or reading data from the sbi0dbr. figure 18-14 changes in the slave address match detection monitor 18.4.13 general call detection monitor sbi0sr2 is set to "1" when sbi0cr1 is "0" and general call (all 8-bit received data is "0" immediately after a start condition) in a slave mode. setting sbi0cr1 to "1" disables the subsequent slave address match and general call de- tections. sbi0sr2 remains at "0" even if a "general call" is received. sbi0sr2 is cleared to "0" when a start or stop condition is detected on a bus. figure 18-15 changes in the general call detection monitor tmp89ch42 18. serial bus interface (sbi) 18.4 functions page 284 ra002 start condition stop condition output of an acknowledge signal general call scl (bus) sda (bus) sda0 pin sbi0sr2 intsbi0 interrupt request 23456789 1 start condition scl0 (bus) sda0 (bus) sda0 pin sbi0sr2 intsbi0 interrupt request output of an acknowledge signal writing or reading sbi0dbr slave address + direction bit 23456789 1 sa6 sa5 sa4 sa3 sa2 sa1 sa0 r/w
18.4.14 last received bit monitor the sda line value stored at the rising edge of the scl line is set to sbi0sr2. in the acknowledge mode, immediately after an interrupt request is generated, an acknowledge signal is read by reading the contents of sbi0sr2. figure 18-16 changes in the last received bit monitor 18.4.15 slave address and address recognition mode specification when the serial bus interface circuit is used in the i 2 c bus mode, clear i2c0ar to "0", and set i2c0ar to the slave address. when the serial bus interface circuit is used with a free data format not to recognize the slave address, set i2c0ar to "1". with a free data format, the slave address and the direction bit are not recognized, and they are processed as data from immediately after the start condition. tmp89ch42 page 285 ra002 acknowledgment 23456789 1 d7 d6 d5 d4 d3 d2 d1 d0 d6 d7 d5 d4 d3 d2 d1 d acknowledgment scl sda sbi0sr2
18.5 data transfer of i 2 c bus 18.5.1 device initialization set poffcr1 to "1". after confirming that the serial bus interface pin is high level, set sbi0cr2 to "1" to select the serial bus interface mode. set sbi0cr1 to "1", sbi0cr1 to "0" and sbi0cr1 to "000" to count the number of clocks for an acknowledge signal, to enable the slave address match detection and the general call detection, and set the data length to 8 bits. set t high and t low at sbi0cr1. set a slave address at i2c0ar and set i2c0ar to "0" to select the i 2 c bus mode. finally, set sbi0cr2, sbi0cr2 and sbi0cr2 to "0", sbi0cr2 to "1" and sbi0cr2 to "00" for specifying the default setting to a slave receiver mode. note: the initialization of a serial bus interface circuit must be complete within the time from all devices which are connected to a bus have initialized to and device does not generate a start condition. if not, the data can not be received correctly because the other device starts transferring before an end of the initiali- zation of a serial bus interface circuit. example :initialize a device chk_port: ld a, (p2prd) ; checks whether the serial bus interface pin is at the high level and a, 0x18 cmp a, 0x18 jr nz, chk_port ld (sbi0cr2), 0x18 ; selects the serial bus interface mode ld (sbi0cr1), 0x16 ; selects the acknowledgment mode and sets sbi0cr1 to "110" ld (i2c0ar), 0xa0 ; sets the slave address to 1010000 and selects the i2c bus mode ld (sbi0cr2), 0x18 ; selects the slave receiver mode 18.5.2 start condition and slave address generation confirm a bus free status (sbi0sr2="0"). set sbi0cr1 to "1" and specify a slave address and a direction bit to be transmitted to the sbi0dbr. by writing "1" to sbi0cr2, sbi0cr2, sbi0cr2 and sbi0cr2, the start condi- tion is generated on a bus and then, the slave address and the direction bit which are set to the sbi0dbr are output. the time from generating the start condition until the falling sbi0 pin takes t high . an interrupt request occurs at the 9th falling edge of a scl clock cycle, and sbi0cr2 is cleared to "0". the scl0 pin is pulled down to the low level while sbi0cr2 is "0". when an interrupt request occurs, sbi0cr2 changes by the hardware according to the direction bit only when an acknowledge signal is returned from the slave device. note 1: do not write a slave address to the sbi0dbr while data is transferred. if data is written to the sbi0dbr, data to be output may be destroyed. note 2: the bus free state must be confirmed by software within 98.0 s (the shortest transmitting time according to the standard mode i 2 c bus standard) or 23.7s (the shortest transmitting time according to the fast mode i 2 c bus standard) after setting of the slave address to be output. only when the bus free state is confirmed, set "1" to sbi0cr2, sbi0cr2, sbi0cr2 and sbi0cr2 to generate the start con- ditions. if the writing of slave address and setting of sbi0cr2, sbi0cr2, sbi0cr2 and sbi0cr2 doesn't finish within 98.0s or 23.7s, the other masters may start the transferring and the slave address data written in sbi0dbr may be broken. tmp89ch42 18. serial bus interface (sbi) 18.5 data transfer of i 2 c bus page 286 ra002
example :generate the start condition chk_bb: test (sbi0sr2).bb ; confirms that the bus is free jr f, chk_bb ld (sbi0dbr), 0xcb ; the transmission slave address 0x65 and the direction bit "1" ld (sbi0cr2), 0xf8 ; write "1" to sbi0cr2, , and to "1" figure 18-17 generating the start condition and the slave address 18.5.3 1-word data transfer check sbi0sr2 by the interrupt process after a 1-word data transfer is completed, and determine whether the mode is a master or slave. 18.5.3.1 when sbi0sr2 is "1" (master mode) check sbi0sr2 and determine whether the mode is a transmitter or receiver. (1) when sbi0sr2 is "1" (transmitter mode) check sbi0sr2. when sbi0sr2 is "1", a receiver does not request data. implement the process to generate a stop condition (described later) and terminate data transfer. when sbi0sr2 is "0", the receiver requests subsequent data. when the data to be transmitted subsequently is other than 8 bits, set sbi0cr1 again, set sbi0cr1 to "1", and write the transmitted data to sbi0dbr. after writing the data, sbi0cr2 becomes "1", a serial clock pulse is generated for transferring the subsequent 1-word data from the scl0 pin, and then the 1-word data is transmitted from the sda0 pin. after the data is transmitted, an interrupt request occurs. sbi0cr2 become "0" and the scl0 pin is set to the low level. if the data to be transferred is more than one word in length, repeat the procedure from the sbi0sr2 checking above. tmp89ch42 page 287 ra002 start condition scl0 pin sda0 pin sbi0cr1 sbi0cr2 interrupt request signal slave address + direction bit 23456789 1 acknowledgem ent signal from a slave sbi0cr2 is cleared to "0" when the direction bit is "1"and an acknowledge signal is returned.
figure 18-18 example when sbi0cr1="000" and sbi0cr1="1" (2) when sbi0sr2 is "0" (receiver mode) when the data to be transmitted subsequently is other than 8 bits, set sbi0cr1 again. set sbi0cr1< ack> to "1" and read the received data from the sbi0dbr (reading data is undefined immediately after a slave address is sent). after the data is read, sbi0cr2 becomes "1" by writing the dummy data (0x00) to the sbi0dbr. the serial bus interface circuit outputs a serial clock pulse to the scl0 pin to transfer the subsequent 1-word data and sets the sda0 pin to "0" at the acknowledge signal timing. an interrupt request occurs and sbi0cr2 becomes "0". then a serial bus interface circuit outputs a clock pulse for 1-word data transfer and the acknowledge signal by writing data to the sbi0dbr or setting sbi0cr2 to "1" after reading the received data. figure 18-19 example when sbi0cr1="000" and sbi0cr1="1" to make the transmitter terminate transmission, execute following procedure before receiving a last data. 1. read the received data. 2. clear sbi0cr1 to "0" and set sbi0cr1 to "000". 3. to set sbi0cr2 to "1", write a dummy data (0x00) to sbi0dbr. transfer 1-word data in which no clock is generated for an acknowledge signal by setting sbi0cr2 to "1". next, execute following procedure. 1. read the received data. 2. clear sbi0cr1 to "0" and set sbi0cr1 to "001". tmp89ch42 18. serial bus interface (sbi) 18.5 data transfer of i 2 c bus page 288 ra002 acknowledge signal to the transmitter 23456789 9 1 d7 read sbi0dbr scl0 pin sda0 pin sbi0cr2 intsbi0 interrupt request write to sbi0dbr new d7 d5 d6 d4 d3 d2 d1 d0 23456789 1 acknowledge signal from the receiver d7 d6 d5 d4 d3 d2 d1 d0 scl0 pin sda0 pin sbi0cr2 intsbi0 interrupt request write to sbi0dbr
3. to set sbi0cr2 to "1", write a dummy data (0x00) to sbi0dbr. transfer 1-bit data by setting sbi0cr1 to "1". in this case, since the master device is a receiver, the sda line on a bus keeps the high level. the transmitter receives the high-level signal as a negative acknowledge signal. the receiver indicates to the transmitter that data transfer is complete. after 1-bit data is received and an interrupt request has occurred, generate the stop condition to terminate data transfer. figure 18-20 termination of data transfer in the master receiver mode 18.5.3.2 when sbi0sr2 is "0" (slave mode) in the slave mode, a serial bus interface circuit operates either in the normal slave mode or in the slave mode after losing arbitration. in the slave mode, the conditions of generating the serial bus interface interrupt request (intsbi0) are follows: ? at the end of the acknowledge signal when the received slave address matches the value set by the i2c0ar with sbi0cr1 set at "0" ? at the end of the acknowledge signal when a "general call" is received with sbi0cr1 set at "0" ? at the end of transferring or receiving after matching of slave address or receiving of "general call" the serial bus interface circuit changes to the slave mode if arbitration is lost in the master mode. and an interrupt request occurs when the word data transfer terminates after losing arbitration. the generation of the interrupt request and the behavior of sbi0cr2 after losing arbitration are shown in table 18-4. table 18-4 the behavior of an interrupt request and sbi0cr2 after losing arbitration when the arbitration lost occurs during transmission of slave address as a master when the arbitration lost occurs during transmission of data as master transmitter interrupt request an interrupt request is generated at the termination of word-data transfer. sbi0cr2 sbi0cr2 is cleared to "0". when an interrupt request occurs, sbi0cr2 is reset to "0", and the scl0 pin is set to the low level. either writing data to the sbi0dbr or setting sbi0cr2 to "1" releases the scl0 pin after taking t low . tmp89ch42 page 289 ra002 negative acknowledge signal to the transmitter after reading the received data, clear sbi0cr1 to "0" and writing the dummy data (0x00) scl0 pin sda0 pin sbi0cr intsbi0 interrupt request after reading the reveived data, set sbi0cr1 to "001" and write dummy data (0x00) 2345678 1 9 d7 d5 d6 d4 d3 d2 d1 d0
check sbi0sr2, sbi0sr2, sbi0sr2 and sbi0sr2 and implement process- es according to conditions listed in table 18-5. table 18-5 operation in the slave mode sbi0sr2< trx> sbi0sr2< al> sbi0sr2< aas> sbi0sr2< ad0> conditions process 1 1 1 0 the serial bus interface circuit loses arbi- tration when transmitting a slave address, and receives a slave address of which the value of the direction bit sent from another master is "1". set the number of bits in 1 word to sbi0cr1 and write the transmitted data to the sbi0dbr. 0 1 0 in the slave receiver mode, the serial bus interface circuit receives a slave address of which the value of the direction bit sent from the master is "1". 0 0 in the slave transmitter mode, the serial bus interface circuit finishes the transmis- sion of 1-word data check sbi0sr2. if it is set to "1", set sbi0cr2 to "1" since the receiver does not request subsequent data. then, clear sbi0cr2 to "0" to release the bus. if sbi0sr2 is set to "0", set the number of bits in 1 word to sbi0cr1 and write the transmitted data to sbi0dbr since the receiver requests subsequent da- ta. 0 1 1 1/0 the serial bus interface circuit loses arbi- tration when transmitting a slave address, and receives a slave address of which the value of the direction bit sent from another master is "0" or receives a "general call". write the dummy data (0x00) to the sbi0dbr to set sbi0cr2 to "1", or write "1" to sbi0cr2. 0 0 the serial bus interface circuit loses arbi- tration when transmitting a slave address or data, and terminates transferring the word data. the serial bus interface circuit is changed to the slave mode. write the dummy data (0x00) to the sbi0dbr to clear sbi0sr2 to "0" and set sbi0cr2 to "1". 0 1 1/0 in the slave receiver mode, the serial bus interface circuit receives a slave address of which the value of the direction bit sent from the master is "0" or receives "gen- eral call". write the dummy data (0x00) to the sbi0dbr to set sbi0cr2 to "1", or write "1" to sbi0cr2. 0 1/0 in the slave receiver mode, the serial bus interface circuit terminates the receipt of 1-word data. set the number of bits in 1-word to sbi0cr1, read the received data from the sbi0dbr and write the dummy data (0x00). note: in the slave mode, if the slave address set in i2c0ar is "0x00", a start byte "0x01" in i 2 c bus standard is received, the device detects slave address match and sbi0cr2 is set to "1". do not set i2c0ar to "0x00". 18.5.4 stop condition generation when sbi0cr2 is "1", a sequence of generating a stop condition is started by setting "1" to sbi0cr2, sbi0cr2 and sbi0cr2 and clearing sbi0cr2 to "0". do not modify the contents of sbi0cr2, sbi0cr2, sbi0cr2 and sbi0cr2 until a stop condition is generated on a bus. when a scl line on a bus is pulled down by other devices, a serial bus interface circuit generates a stop condition after a scl line is released. the time from the releasing scl line until the generating the stop condition takes t high . tmp89ch42 18. serial bus interface (sbi) 18.5 data transfer of i 2 c bus page 290 ra002
example :generate the stop condition ld (sbi0cr2), 0xd8 ; sets sbi0cr2, and to "1" and sbi0cr2 to "0" chk_bb: test (sbi0sr2).bb ;waits until the bus is set free jr t, chk_bb figure 18-21 stop condition generation 18.5.5 restart restart is used to change the direction of data transfer between a master device and a slave device during transferring data. the following explains how to restart the serial bus interface circuit. clear sbi0cr2, sbi0cr2 and sbi0cr2 to "0" and set sbi0cr2 to "1". the sda0 pin retains the high level and the scl0 pin is released. since this is not a stop condition, the bus is assumed to be in a busy state from other devices. check sbi0sr2 until it becomes "0" to check that the scl0 pin of the serial bus interface circuit is released. check sbi0sr2 until it becomes "1" to check that the scl line on the bus is not pulled down to the low level by other devices. after confirming that the bus stays in a free state, generate a start condition in the procedure "18.5.2 start condition and slave address generation". in order to meet the setup time at a restart, take at least 4.7 s of waiting time by the software in the standard mode i 2 c bus standard or at least 0.6 s of waiting time in the fast mode i 2 c bus standard from the time of restarting to confirm that a bus is free until the time to generate a start condition. note: when the master is in the receiver mode, it is necessary to stop the data transmission from the slave device before the stop condition is generated. to stop the transmission, the master device make the slave device receiving a negative acknowledge. therefore, sbi0sr2 is "1" before generating the restart and it can not be confirmed that scl line is not pulled down by other devices. please confirm the scl line state by reading the port. tmp89ch42 page 291 ra002 stop condition if the scl of the bus is pulled down by other devices, the stop condition is generated after it is released sbi0cr2="1" sbi0cr2="1" sbi0cr2="0" sbi0cr2="1" scl0 pin scl (bus) sda0 pin sbi0cr2 sbi0sr2
example :generate a restart ld (sbi0cr2), 0x18 ; sets sbi0cr2, and to "0" and sbi0cr2 to "1" chk_bb: test (sbi0sr2).bb ; waits until sbi0sr2 becomes "0" jr t, chk_bb chk_lrb: test (sbi0sr2).lrb ; waits until sbi0sr2 becomes "1" jr f, chk_lrb . . ; wait time process by the software . ld (sbi0cr2), 0xf8 ; sets sbi0cr2, , and to "1" figure 18-22 timing diagram when restarting tmp89ch42 18. serial bus interface (sbi) 18.5 data transfer of i 2 c bus page 292 ra002 start condition sbi0cr2="0" sbi0cr2="0" sbi0cr2="0" sbi0cr2="1" scl (bus) scl0 pin sda0 pin sbi0sr2 sbi0sr2 sbi0cr2 sbi0cr2="1" sbi0cr2="1" sbi0cr2="1" sbi0cr2="1" 4.7 s min. in the normal mode or 0.6 s min. in the fast mode
18.6 ac specifications the ac specifications are as listed below. the operating mode (fast or standard) mode should be selected suitable for frequency of fcgck. for these operating mode, refer to the following table. table 18-6 ac specifications (circuit output timing) parameter symbol standard mode fast mode unit min. max. min. max. scl clock frequency f scl 0 fcgck / (m+n) 0 fcgck / (m+n) khz hold time (re)start condition. this peri- od is followed by generation of the first clock pulse. t hd;sta m / fcgck - m / fcgck - s low-level period of scl clock (output) t low n / fcgck - n / fcgck - s high-level period of scl clock (output) t high m / fcgck - m / fcgck - s low-level period of scl clock (input) t low 5 / fcgck - 5 / fcgck - s high-level period of scl clock (input) t high 3 / fcgck - 3 / fcgck - s restart condition setup time t su;sta depends on the software - depends on the software - s data hold time t hd;dat 0 5 / fcgck 0 5 / fcgck s data setup time t su;dat 250 - 100 - ns rising time of sda and scl signals t r - 1000 - 300 ns falling time of sda and scl signals t f - 300 - 300 ns stop condition setup time t su;sto m / fcgck - m / fcgck - s bus free time between the stop condi- tion and the start condition t buf depends on the software - depends on the software - s time before rising of scl after sbicr2 is changed from "0" to "1" t su;scl n / fcgck - n / fcgck - s note:for m and n, refer to"18.4.4.1 clock source". figure 18-23 definition of timing (no. 1) tmp89ch42 page 293 ra002 t low t f t f t su;sta t su;sto t buf t hd;sta t r t su;dat t hd;sta t high t hd;dat t f
figure 18-24 definition of timing (no. 2) tmp89ch42 18. serial bus interface (sbi) 18.6 ac specifications page 294 ra002 scl sbicr2 su;scl t
18.7 revision history rev description ra001 " serial bus interface control register 1" revised sck description. added note5. "18.6 ac specifications" revised fcgck description. "table 18-8 ac specifications (circuit output timing)" revised value of "scl clock frequency". revised from "normal mode" to "standard mode". ra002 "18.5.1 device initialization" revised example of program. tmp89ch42 page 295 ra002
tmp89ch42 18. serial bus interface (sbi) 18.7 revision history page 296 ra002
19. key-on wakeup (kwu) the key-on wakeup is a function for releasing the stop mode at the stop pin or at pins kwi7 through kwi0. 19.1 configuration figure 19-1 key-on wakeup circuit tmp89ch42 page 297 ra000 stop mode release signal (to be released if set to ?1?) syscr1 selector port port port port port rising edge detection 0 1 s y 76543210 kwucr0 (0x0fc4) port port port port 76543210 kwucr1 (0x0fc5) kwi0 kwi1 kwi2 kwi3 kwi4 kwi5 kwi6 kwi7 stop
19.2 control key-on wakeup control registers (kwucr0 and kwucr1) can be configured to designate the key-on wakeup pins (kwi7 through kwi0) as stop mode release pins and to specify the stop mode release levels of each of these designated pins. key-on wakeup control register 0 kwucr0 7 6 5 4 3 2 1 0 (0x0fc4) bit symbol kw3le kw3en kw2le kw2en kw1le kw1en kw0le kw0en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 kw3le stop mode release level of kwi3 pin 0: 1: low level high level kw3en input enable/disable control of kwi3 pin 0: 1: disable enable kw2le stop mode release level of kwi2 pin 0: 1: low level high level kw2en input enable/disable control of kwi2 pin 0: 1: disable enable kw1le stop mode release level of kwi1 0: 1: low level high level kw1en input enable/disable control of kwi1 pin 0: 1: disable enable kw0le stop mode release level of kwi0 pin 0: 1: low level high level kw0en input enable/disable control of kwi0 pin 0: 1: disable enable key-on wakeup control register 1 kwucr1 7 6 5 4 3 2 1 0 (0x0fc5) bit symbol kw7le kw7en kw6le kw6en kw5le kw5en kw4le kw4en read/write r/w r/w r/w r/w r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 kw7le stop mode release level of kwi7 pin 0: 1: low level high level kw7en input enable/disable control of kwi7 pin 0: 1: disable enable kw6le stop mode release level of kwi6 pin 0: 1: low level high level kw6en input enable/disable control of kwi6 pin 0: 1: disable enable kw5le stop mode release level of kwi5 pin 0: 1: low level high level kw5en input enable/disable control of kwi5 pin 0: 1: disable enable kw4le stop mode release level of kwi4 pin 0: 1: low level high level kw4en input enable/disable control of kwi4 pin 0: 1: disable enable tmp89ch42 19. key-on wakeup (kwu) 19.2 control page 298 ra000
19.3 functions by using the key-on wakeup function, the stop mode can be released at a stop pin or at kwim pin (m: 0 through 7 ). after resetting, the stop pin is the only stop mode release pin. to designate the kwim pin as a stop mode release pin, therefore, it is necessary to configure the key-on wakeup control register (kwucrn) (n: 0 or 1). because the stop pin lacks a function for disabling inputs, it can be designated as a pin for receiving a stop mode release signal, irrespective of whether the key-on wakeup function is used or not. ? setting kwucrn and p4pu registers to designate a key-on wakeup pin (kwim) as a stop mode release pin, set kwucrn to "1". after kwim pin is set to "1" at kwucrn, a specific stop mode release level can be specified for this pin at kwucrn. if kwucrn is set to "0", stop mode is released when an input is at a low level. if it is set to "1", stop mode is released when an input is at a high level. for example, if you want to release stop mode by inputting a high-level signal into a kwi0 pin, set kwucr0 to "1", " and kwucr0 to "1". each kwim pin can be connected to internal pull-up resistors. before connecting to internal pull-up re- sistors, the corresponding bits in the pull-up control register (p4pu) at port p4 must be set to "1". ? starting stop mode to start the stop mode, set syscr1 to "1" (level release mode), and syscr1 to "1". to use the key-on wakeup function, do not set syscr1 to "0" (edge release mode). if the key- on wakeup function is used in edge release mode, stop mode cannot be released, although a rising edge is input into the stop pin. this is because the kwim pin enabling inputs to be received is at a release level after the stop mode starts. ? releasing stop mode to release stop mode, input a high-level signal into the stop pin or input a specific release level into the kwim pin for which receipt of inputs is enabled. if you want to release stop mode at the kwim pin, rather than the stop pin, continue inputting a low-level signal into the stop pin throughout the period from when the stop mode is started to when it is released. if the stop pin or kwim pin is already at a release level when the stop mode starts, the following instruction will be executed without starting the stop mode (with no warm-up performed). note 1: if an analog voltage is applied to kwim pin for which receipt of inputs is enabled by the key-on wakeup control register (kwucrn) setting, a penetration current will flow. therefore, in this case, the analog voltage should be not applied to this pin. table 19-1 stop mode release level (edge) pin name release level (edge) syscr1="1" (level release mode) syscr1="0" (edge release mode) kwucrn="0" kwucrn="1" stop "h" level rising edge kwim "l" level "h" level don't use tmp89ch42 page 299 ra000
example :a case in which stop mode is started with the release level of the stop pin set to a high level and the release level of kwi0 set to a low level (connected to an internal pull-up resistor of the kwi0 pin) di ; imf0 set (p4pu).0 ; kwi0 (p40) connected to a pull-up resistor ld (kwucr0), 0y00000001 ; the kwi0 pin is set to enable inputs, and its release level is set ; to a low level. ld (syscr1), 0y10100000 ; starting in level release mode tmp89ch42 19. key-on wakeup (kwu) 19.3 functions page 300 ra000
20. 10-bit ad converter (adc) the tmp89ch42 has a 10-bit successive approximation type ad converter. 20.1 configuration the circuit configuration of the 10-bit ad converter is shown in figure 20-1. it consists of control registers adccr1 and adccr2, converted value registers adcdrl and adcdrh, a da converter, a sample-hold circuit, a comparator, a successive comparison circuit, etc. figure 20-1 10-bit ad converter note 1: before using the ad converter, set an appropriate value to the i/o port register which is also used as an analog input port. for details, see the section on "i/o ports". note 2: the da converter current (iref) is automatically cut off at times other than during ad conversion. tmp89ch42 page 301 ra002 4 10 ainds r/2 r/2 r sain n sample-hold circuit a s en da converter input selector y reference voltage 2 10 8 8 s r d a ack amd ad converted value registers 1 and 2 ad converter control registers 1 and 2 f b d a l e s r f c o e intadc adccr2 adcdrl adcdrh adccr1 control circuit shift clock analog comparator 3 selector successive approximation circuit vss varef/avdd ain0 ain7
20.2 control the ad converter consists of the following four registers: 1. ad converter control register 1 (adccr1) this register selects an analog channel in which to perform ad conversion, selects an ad conversion operation mode, and controls the start of the ad converter. 2. ad converter control register 2 (adccr2) this register selects the ad conversion time, and monitors the operating status of the ad converter. 3. ad converted value registers (adcdrh and adcdrl) these registers store the digital values generated by the ad converter. tmp89ch42 20. 10-bit ad converter (adc) 20.2 control page 302 ra002
ad converter control register 1 adccr1 7 6 5 4 3 2 1 0 (0x0034) bit symbol adrs amd ainen sain read/write r/w r/w r/w r/w after reset 0 0 0 0 0 0 0 0 adrs ad conversion start 0: 1: - ad conversion start amd ad operating mode 00: 01: 10: 11: ad operation disable, forcibly stop ad operation single mode reserved repeat mode ainen analog input control 0: 1: analog input disable analog input enable sain analog input channel select 0000: 0001: 0010: 0011: 0100: 0101: 0110: 0111: 1000: 1001: 1010: 1011: 1100: 1101: 1110: 1111: ain0 ain1 ain2 ain3 ain4 ain5 ain6 ain7 reserved reserved reserved reserved reserved reserved reserved reserved note 1: do not perform the following operations on the adccr1 register while ad conversion is being executed (adccr2="1"). - changing sain - setting ainen to "0" - changing amd (except a forced stop by setting amd to "00") - setting adrs to "1" note 2: if you want to disable all analog input channels, set ainen to "0". note 3: although analog input pins are also used as input/output ports, it is recommended for the purpose of maintaining the accuracy of ad conversion that you do not execute input/output instructions during ad conversion. additionally, do not input widely varying signals into the ports adjacent to analog input pins. note 4: when stop, idle0 or slow mode is started, adrs, amd and ainen are initialized to "0". if you use the ad converter after returning to normal mode, you must reconfigure adrs, amd and ainen. note 5: after the start of ad conversion, adrs is automatically cleared to "0" ("0" is read). tmp89ch42 page 303 ra002
ad converter control register 2 adccr2 7 6 5 4 3 2 1 0 (0x0035) bit symbol eocf adbf - - "0" ack read/write r r r r w r/w after reset 0 0 0 0 0 0 0 0 eocf ad conversion end flag 0: 1: before conversion or during conversion conversion end adbf ad conversion busy flag 0: 1: ad conversion being halted ad conversion being executed ack ad conversion time select (exam- ples of ad conversion time are shown in the table below) 000: 001: 010: 011: 100: 101: 110: 111: 39/fcgck 78/fcgck 156/fcgck 312/fcgck 624/fcgck 1248/fcgck reserved reserved note 1: make sure that you make the ack setting when ad conversion is in a halt condition (adccr2="0"). note 2: make sure that you write "0" to bit 3 of adccr2. note 3: if stop, idle0 or slow mode is started, eocf and adbf are initialized to "0". note 4: if the ad converted value register (adcdrh) is read, eocf is cleared to "0". it is also cleared to "0" if ad conversion is started (adccr1="1") without reading adcdrh after completing ad conversion in single mode. note 5: if an instruction to read adccr2 is executed, 0 is read from bits 3 through 5. table 20-1 ack settings and conversion times relative to frequencies frequency (fcgck) ack setting conversion time 10mhz 8mhz 5mhz 4mhz 2.5mhz 2mhz 1mhz 0.5mhz 0.25 mhz 000 39/fcgck - - - - 15.6 s 19.5 s 39.0 s 78.0 s 156.0 s 001 78/fcgck - - 15.6 s 19.5 s 31.2 s 39.0 s 78.0 s 156.0 s - 010 156/fcgck 15.6 s 19.5 s 31.2 s 39.0 s 62.4 s 78.0 s 156.0 s - - 011 312/fcgck 31.2 s 39.0 s 62.4 s 78.0 s 124.8 s 156.0 s - - - 100 624/fcgck 62.4 s 78.0 s 124.8 s 156.0 s - - - - - 101 1248/fcgck 124.8 s 156.0 s - - - - - - - 11* reserved note 1: spaces indicated by "-" in the above table mean that it is prohibited to establish conversion times in these spaces. fcgck: high frequency oscillation clock [hz] note 2: above conversion times do not include the time shown below. - time from when adccr1 is set to 1 to when ad conversion is started - time from when ad conversion is finished to when a converted value is stored in adcdrl and adcdrh. if ack = 00*, the longest conversion time is 10/fcgck (s). if ack = 01*, it is 32/fcgck (s). if ack = 10*, it is 128/fcgck(s). note 3: the conversion time must be longer than the following time by analog reference voltage (varef). - varef = 4.5 to 5.5 v 15.6 s or longer - varef = 2.7 to 5.5 v 31.2 s or longer - varef = 2.2 to 5.5 v 124.8 s or longer tmp89ch42 20. 10-bit ad converter (adc) 20.2 control page 304 ra002
ad converted value register (lower side) adcdrl 7 6 5 4 3 2 1 0 (0x0036) bit symbol ad07 ad06 ad05 ad04 ad03 ad02 ad01 ad00 read/write r r r r r r r r after reset 0 0 0 0 0 0 0 0 ad converted value register (upper side) adcdrh 7 6 5 4 3 2 1 0 (0x0037) bit symbol - - - - - - ad09 ad08 read/write r r r r r r r r after reset 0 0 0 0 0 0 0 0 note 1: a read of adcdrl or adcdrh must be read after the intadc interrupt is generated or after adccr2 becomes "1". note 2: in single mode, do not read adcdrl or adcdrh during ad conversion (adccr2="1"). (if ad conversion is finished in the interim between a read of adcdrl and a read of adcdrh, the intadc interrupt request is canceled, and the conversion result is lost.) note 3: if stop, idle0 or slow mode is started, adcdrl and adcdrh are initialized to "0". note 4: if adccr1 is set to "00", adcdrl and adcdrh are initialized to "0". note 5: if an instruction to read adcdrh is executed, "0" is read from bits 7 through 2. note 6: if ad conversion is finished in repeat mode in the interim between a read of adcdrl and a read of adcdrh, the previous converted value is retained without overwriting the ad converted value register. in this case, the intadc interrupt request is canceled, and the conversion result is lost. tmp89ch42 page 305 ra002
20.3 functions the 10-bit ad converter operates in either single mode in which ad conversion is performed only once or repeat mode in which ad conversion is performed repeatedly. 20.3.1 single mode in single mode, the voltage at a designated analog input pin is ad converted only once. setting adccr1 to "1" after setting adccr1 to "01" allows ad conversion to start. adccr1 is automatically cleared after the start of ad conversion. as ad conversion starts, adccr2 is set to "1". it is cleared to "0" if ad conversion is finished or if ad conversion is forced to stop. after ad conversion is finished, the conversion result is stored in the ad converted value registers (adcdrl and adcdrh), adccr2 is set to "1", and the ad conversion finished interrupt (intadc) is gener- ated. the ad converted value registers (adcdrl and adcdrh) should be usually read according to the intadc interrupt processing routine. if the upper side (adcdrh) of the ad converted value register is read, adccr2 is cleared to "0". note: do not perform the following operations on the adccr1 register when ad conversion is being executed (adccr2="1"). if the following operations are performed, there is the possibility that ad con- version may not be executed properly. ? changing the adccr1 setting ? setting adccr1 to "0" ? changing the adccr1 setting (except a forced stop by setting amd to "00") ? setting adccr1 to "1" figure 20-2 single mode 20.3.2 repeat mode in repeat mode, the voltage at an analog input pin designated at adccr1 is ad converted repeatedly. setting adccr1 to "1" after setting adccr1 to "11" allows ad conversion to start. after the start of ad conversion, adccr1 is automatically cleared. after the first ad conversion is finished, the conversion result is stored in the ad converted value registers (adcdrl and adcdrh), adccr2 is set to "1", and the ad conversion finished interrupt (intadc) is generated. after this interrupt is generated, the second (next) ad conversion starts immediately. tmp89ch42 20. 10-bit ad converter (adc) 20.3 functions page 306 ra002 status of adcdrl and adcdrh clearing eocf based on the conversion result read of conversion result read of conversion result read of conversion result read of conversion result adccr2 intadc interrupt request adccr2 adccr1 result of the first conversion result of the second conversion indeterminate ad conversion start ad conversion start read of adcdrh read of adcdrl
the ad converted value registers (adcdrl and addrh) should be read before the next ad conversion is finished. if the next ad conversion is finished in the interim between a read of adcdrl and a read of adcdrh, the previous converted value is retained without overwriting the ad converted value registers (adcdrl and adcdrh). in this case, the intadc interrupt request is not generated, and the conversion result is lost. (see figure 20-3.) to stop ad conversion, write "00" (ad operation disable) to adccr1. as "00" is written to adccr1, ad conversion stops immediately. in this case, the converted value is not stored in the ad converted value register. as ad conversion starts, adccr2 is set to "1". it is cleared to "0" if "00" is written to amd. figure 20-3 repeat mode 20.3.3 ad operation disable and forced stop of ad operation if you want to force the ad converter to stop when ad conversion is ongoing in single mode or if you want to stop the ad converter when ad conversion is ongoing in repeat mode, set adccr1 to "00". if adccr1 is set to "00", registers adccr2, adccr2, adcdrl, and adcdrh are initialized to "0". tmp89ch42 page 307 ra002 status of adcdrl and adcdrh a read of the conversion result will clear eocf. the intadc interrupt request is not generated in the interim between a read of adcdrl and a read of adcdrh. read of conversion result read of conversion result a dccr2 intadc interrupt conversion operation a dccr1 ad conversion start adccr1 ?11? ?00? ad conversion is suspended. the conversion result is not stored. read of adcdrh read of adcdrl read of conversion result read of conversion result read of conversion result read of conversion result indeterminate result of the 1st conversion result of the 2nd conversion result of the 3rd conversion result of the 4th conversion result of the 4th conversion result of the 3rd conversion
20.4 register setting 1. set the ad converter control register 1 (adccr1) as described below: ? from the ad input channel select (sain), select the channel in which ad conversion is to be performed. ? set the analog input control (ainen) to "analog input enable". ? at amd, specify the ad operating mode (single or repeat mode). 2. set the ad converter control register 2 (adccr2) as described below: ? at the ad conversion time (ack), specify the ad conversion time. for information on how to specify the conversion time, refer to the ad converter control register 2 and table 20-1. 3. after the above two steps are completed, set "1" on the ad conversion start (adrs) of the ad converter control register 1 (adccr1), and ad conversion starts immediately if single mode is selected. 4. as ad conversion is finished, the ad conversion end flag (eocf) of the ad converter control register 2 (adccr2) is set to "1", the ad conversion result is stored in the ad converted value registers (adcdrh and adcdrl), and the intadc interrupt request is generated. 5. after the conversion result is read from the ad converted value register (adcdrh), eocf is cleared to "0". eocf will also be cleared to "0" if ad conversion is performed once again before reading the ad converted value register (adcdrh). in this case, the previous conversion result is retained until ad con- version is finished. example: after selecting the conversion time 15.6 s at 10 mhz and the analog input channel ain3 pin, perform ad conversion once. after checking eocf, store the conversion result in the hl register. the operation mode is single mode. : (port setting) ; before setting ad converter registers, make an appropriate port ; register setting.(for further details, refer to the section that describes ; i/o ports.) ld (adccr1), 0y00110011 ; select ain3 and operation mode ld (adccr2), 0y00000010 ; select conversion time (156/fcgck) set (adccr1). 7 ; adrs = 1 (ad conversion start) sloop : test (adccr2). 7 ; eocf = 1 ? j t, sloop ld hl, (adcdrl) ; read result data 20.5 starting stop/idle0/slow modes if stop/idle0/slow mode is started, registers adccr1, adccr2, adcdrl and adcdrh are initialized to "0". if any of these modes is started during ad conversion, ad conversion is suspended, and the ad converter stops (registers are likewise initialized). when restored from stop/ idle0 / slow mode, ad conversion is not automatically restarted. therefore, registers must be reconfigured as necessary. if stop/idle0/slow mode is started during ad conversion, analog reference voltage is automatically discon- nected and, therefore, there is no possibility of current flowing into the analog reference voltage. tmp89ch42 20. 10-bit ad converter (adc) 20.4 register setting page 308 ra002
20.6 analog input voltage and ad conversion result analog input voltages correspond to ad-converted, 10-bit digital values, as shown in figure 20-4. figure 20-4 relationships between analog input voltages and ad-converted values (typical values) tmp89ch42 page 309 ra002 1 0 01 h 02 h 03 h 3fd h 3fe h 3ff h 2 3 1021 1022 1023 1024 analog input voltage 1024 ad-converted value varef/avdd ? vss
20.7 precautions about the ad converter 20.7.1 analog input pin voltage range analog input pins (ain0 through ain7) should be used at voltages from varef to vss. if any voltage outside this range is applied to one of the analog input pins, the converted value on that pin becomes uncertain, and converted values on other pins will also be affected. 20.7.2 analog input pins used as input/output ports analog input pins (ain0 to ain7) are also used as input/output ports. in using one of analog input pins (ports) to execute ad conversion, input/output instructions at all other pins (ports) must not be executed. if they are executed, there is the possibility that the accuracy of ad conversion may deteriorate. this also applies to pins other than analog input pins; if one pin receives inputs or generates outputs, noise may occur and its adjacent pins may be affected by that noise. 20.7.3 noise countermeasure the internal equivalent circuit of the analog input pins is shown in figure 20-5 . the higher the output impedance of the analog input source, the more susceptible it becomes to noise. therefore, make sure the output impedance of the signal source in your design is 5 k or less. it is recommended that a capacitor be attached externally. figure 20-5 analog input equivalent circuit and example of input pin processing tmp89ch42 20. 10-bit ad converter (adc) 20.7 precautions about the ad converter page 310 ra002 da converter analog comparator r nal resistance: r nal capacitance: #!undefined!# k ? (typ) da converter aini analog comparator internal resistance: permissible signal source impedance: internal capacitance: 5 k ? (typ) 5 k ? (max) note) i = 7 to 0 c = 22 pf (typ.)
20.8 revision history rev description ra002 "20.4 register setting" revised adccr2 value and comment of example program. tmp89ch42 page 311 ra002
tmp89ch42 20. 10-bit ad converter (adc) 20.8 revision history page 312 ra002
21. input/output circuit 21.1 control pins the input/output circuitries of the tmp89ch42 control pins are shown below. control pin i/o circuitry remarks xin xout input output refer to the p0 ports in the chapter of input/output ports. xtin xtout input output refer to the p0 ports in the chapter of input/output ports. reset input refer to the p1 ports in the chapter of input/output ports. mode input r = 100 (typ.) tmp89ch42 page 313 ra000 r
tmp89ch42 21. input/output circuit 21.1 control pins page 314 ra000
22. electrical characteristics 22.1 absolute maximum ratings the absolute maximum ratings are rated values which must not be exceeded during operation, even for an instant. any one of the ratings must not be exceeded. if any absolute maximum rating is exceeded, a device may break down or its performance may be degraded, causing it to catch fire or explode resulting in injury to the user. thus, when designing products which include this device, ensure that no absolute maximum rating value will ever be exceeded. (v ss = 0 v) parameter symbol pins ratings unit supply voltage v dd ?0.3 to 6.0 v input voltage v in1 p0, p1, p2 (excluding p23 and p24), p4, p7, p8, p9, pb (tri-state port) ?0.3 to v dd + 0.3 v v in2 p23, p24 (sink open drain port) ?0.3 to v dd + 0.3 v in3 ain0 to ain7 (analog input voltage) ?0.3 to a vdd + 0.3 output voltage v out1 ?0.3 to v dd + 0.3 v output current (per pin) i out1 p0, p1, p2 (excluding p23 and p24), p4, p7, p8, p9, pb (tri-state port) ?1.8 ma i out2 p0, p1, p2, p4, p9 (pull-up resistor) ?0.4 i out3 p0, p1, p2, p4, p74 to p77, p8, p9 (tri-state port) 3.2 i out4 p70 to p73, pb (large current port) 30 output current (total) i out1 p0, p1, p2 (excluding p23 and p24), p4, p7, p8, p9, pb (tri-state port) ?30 i out2 p0, p1, p2, p4, p9 (pull-up resistor) ?4 i out3 p0, p1, p2, p4, p74 to p77, p8, p9 (tri-state port) 60 i out4 p70 to p73, pb (large current port) 120 power dissipation (topr = 85c) p d 250 mw soldering temperature (time) tsld 260 (10 s) c storage temperature tstg ?55 to 125 operating temperature topr ?40 to 85 tmp89ch42 page 315 ra005
22.2 operating conditions the operating conditions for a device are operating conditions under which it can be guaranteed that the device will operate as specified. if the device is used under operating conditions other than the operating conditions (supply voltage, operating temperature range, specified ac/dc values etc.), malfunction may occur. thus, when designing products which include this device, ensure that the operating conditions for the device are always adhered to. (v ss = 0 v, topr = ?40 to 85c) parameter symbol pins condition min max unit supply voltage v dd fc = 10.0 mhz normal1, 2 modes idle0, 1, 2 modes 2.7 5.5 v fc = 8.0 mhz 2.2 fcgck = 10.0 mhz 4.3 fcgck = 4.2 mhz 2.7 fcgck = 2.0 mhz 2.2 fs = 32.768 khz slow1, 2 modes sleep0, 1 modes stop mode input high level v ih1 mode pin v dd 4.5 v v dd 0.70 v dd v v ih2 hysteresis input v dd 0.75 v ih3 v dd < 4.5 v v dd 0.90 input low level v il1 mode pin v dd 4.5 v 0 v dd 0.30 v il2 hysteresis input v dd 0.25 v il3 v dd < 4.5 v v dd 0.10 clock frequency fc xin, xout v dd = 2.2 to 5.5 v 1.0 8.0 mhz v dd = 2.7 to 5.5 v 1.0 10.0 fcgck v dd = 2.2 to 5.5 v 0.25 2.0 v dd = 2.7 to 5.5 v 4.2 v dd = 4.3 to 5.5 v 10.0 fs xtin, xtout v dd = 2.2 to 5.5 v 30.0 34.0 khz figure 22-1 clock gear (fcgck) and high-frequency clock (fc) tmp89ch42 22. electrical characteristics 22.2 operating conditions page 316 ra005 5.5 4.3 2.7 0.250 2 1 2 4 4.2 4.2 10 [mhz] gear clock(fcgck) frequency range [v] 2.2 5.5 4.3 2.7 [mhz] high-frequency clock(fc) frequency range fc, fc/2 or fc/4 can be used as gear clock (fcgck). only fc/2 or fc/4 can be used as gear clock (fcgck). only fc/4 can be used as gear clock (fcgck). [v] 2.2 8 8.4 10 (a) (b) (c) (c) (c) (b) (b) (a)
22.3 dc characteristics (v ss = 0 v, topr = ?40 to 85c) parameter symbol pins condition min typ. max unit hysteresis voltage v hs hysteresis input v dd = 5.5 v v in = v mode = 5.5 v/0 v ? 0.9 ? v input current i in1 mode ? ? 2 a i in2 p0, p1, p2, p4, p5, p7, p8, p9, pb i in3 reset, stop input resistance r in2 reset pull-up v dd = 5.5 v, v in = v mode = 0 v 100 220 500 k r in3 p0, p1, p2 (excluding p23 and p24), p4, p9 pull-up 30 50 100 output leakage current i lo1 p23, p24 (skin open drain port) v dd = 5.5 v, v out = 5.5 v ? ? 2 a i lo2 p0, p1, p2 (excluding p23 and p24), p4, p5, p7, p8, p9, pb (tri- state port) v dd = 5.5 v, v out = 5.5 v/0 v ? ? 2 output high voltage v oh except p23, p24, xout, xtout v dd = 4.5 v, i oh = ?0.7 ma 4.1 ? ? v output low voltage v ol except xout, xtout v dd = 4.5 v, i ol = 1.6 ma ? ? 0.4 output low current i ol p70 to p73, pb (large current port) v dd = 4.5 v, v ol = 1.0 v ? 20 ? ma note 1: typical values show those at topr = 25c and v dd = 5.0 v. note 2: input current i in3 : the current through pull-up resistor is not included. note 3: v in : the input voltage on the pin except mode pin, v mode : the input voltage on the mode pin (v ss = 0 v, topr = ?40 to 85c) parameter symbol pins condition min typ. max unit supply current in nor- mal 1, 2 modes i dd v dd = 5.5 v v in = 5.3 v/0.2 v fcgck = 10.0 mhz fs = 32.768 khz ? 8.3 10.5 ma supply current in idle0, 1, 2 modes ? 5.2 7.5 supply current in slow1 mode v dd = 3.0 v v in = 2.8 v/0.2 v v mode =2.8v/0.1v fs = 32.768 khz ? 11 22 a supply current in sleep1 mode ? 10 21 supply current in sleep0 mode ? 9 20 supply current in stop mode v dd = 5.5 v v in = 5.3 v/0.2 v v mode =5.3v/0.1v ? 8 20 note 1: typical values shown are topr = 25c and v dd = 5.0 v, unless otherwise specified. note 2: i dd does not include i ref . it is the electrical current in the state in which the peripheral circuitry has been operated. note 3: each supply current in slow2 mode is equivalent to that in idle0, idle1 and idle2 modes. tmp89ch42 page 317 ra005
22.4 ad conversion characteristics (v ss = 0.0 v, 4.5 v v dd 5.5 v, topr = ?40 to 85c) parameter symbol condition min typ. max unit analog reference voltage / power sup- ply voltage of analog control circuit v aref / a vdd v dd v analog input voltage range v ain v ss ? v aref power supply current of analog refer- ence voltage i ref v dd = a vdd / v aref = 5.5 v v ss = 0.0 v ? 0.6 1.0 ma non-linearity error (note4) v dd = a vdd / v aref = 5.0 v v ss = 0.0v ? ? 89cm42 89ch42 89fm42 89fh42 lsb 4 3 zero point error (note4) ? ? 4 3 full scale error (note4) ? ? 4 3 total error (note4) ? ? 4 3 (v ss = 0.0 v, 2.7 v v dd < 4.5 v, topr = ?40 to 85c) parameter symbol condition min typ. max unit analog reference voltage / power sup- ply voltage of analog control circuit v aref / a vdd v dd v analog input voltage range v ain v ss ? v aref power supply current of analog refer- ence voltage i ref v dd = a vdd / v aref = 4.5 v v ss = 0.0 v ? 0.5 0.8 ma non-linearity error (note4) v dd = a vdd / v aref = 2.7 v v ss = 0.0v ? ? 89cm42 89ch42 89fm42 89fh42 lsb 4 3 zero point error (note4) ? ? 4 3 full scale error (note4) ? ? 4 3 total error (note4) ? ? 4 3 (v ss = 0.0 v, 2.2 v v dd < 2.7 v, topr = ?40 to 85c) parameter symbol condition min typ. max unit analog reference voltage / power sup- ply voltage of analog control circuit v aref / a vdd v dd v analog input voltage range v ain v ss ? v aref power supply current of analog refer- ence voltage i ref v dd = a vdd / v aref = 2.7 v v ss = 0.0 v ? 0.3 0.5 ma non-linearity error (note4) v dd = a vdd / v aref = 2.2 v, v ss = 0.0 v ? ? 89cm42 89ch42 89fm42 89fh42 lsb 5 4 zero point error (note4) ? ? 5 4 full scale error (note4) ? ? 5 4 total error (note4) ? ? 5 4 note 1: the total error includes all errors except a quantization error, and is defined as the maximum deviation from the ideal conversion line. note 2: conversion times differ with variation in the power supply voltage. note 3: the voltage to be input to the ain input pin must be within the range v aref to v ss . if a voltage outside this range is input, converted values will become indeterminate, and converted values of other channels will be affected. note 4: ad conversion characteristics differ between tmp89fm42/fh42 and tmp89cm42/ch42. note 5: if the ad converter is not used, fix the v aref /a vdd pin to the v dd level. tmp89ch42 22. electrical characteristics 22.4 ad conversion characteristics page 318 ra005
22.5 power-on reset circuit characteristics figure 22-2 power-on reset operation timing note: care must be taken in system designing since the power-on reset circuit may not fulfill its functions due to the fluctuations in the power supply voltage (v dd ). (v ss =0 v, topr = ?40 to 85c) symbol parameter min. typ. max. unit v proff power-on reset releasing voltage note 1.85 2.02 2.19 v v pron power-on reset detecting voltage note 1.70 1.85 2.00 t proff power-on reset releasing response time ? 0.01 0.1 ms t pron power-on reset detecting response time ? 0.01 0.1 t prw power-on reset minimum pulse width 1.0 ? ? t pwup warming-up time after a reset is cleared ? 102 x 2 9 /fc ? s t vdd power supply rise time ? ? 5 ms note 1: because the power-on reset releasing voltage and the power-on reset detecting voltage change relative to one another, the detected voltage will never become inverted. note 2: a clock output by an oscillating circuit is used as the input clock for a warming-up counter. because the oscillation fre- quency does not stabilize until an oscillating circuit stabilizes, some errors may be included in the warming-up time. note 3: boost the power supply voltage such that t vdd becomes smaller that t pwup . tmp89ch42 page 319 ra005 power supply voltage (v dd ) v proff operating voltage v pron t vdd t ppw t pron warm-up counter start t pwup t proff power-on reset signal cpu and peripheral circuit reset signal warm-up counter clock
22.6 voltage detecting circuit characteristics figure 22-3 operation timing of the voltage detecting circuit note: care must be taken in system designing since the power-on reset circuit may not fulfill its functions due to the fluctuations in the power supply voltage (v dd ). (v ss = 0 v, topr = ?40 to 85c) symbol parameter min. typ. max. unit t vltoff voltage detection releasing response time ? 0.01 0.1 ms t vlton voltage detecting detection response time ? 0.01 0.1 t vltpw voltage detecting minimum pulse width 1.0 ? ? tmp89ch42 22. electrical characteristics 22.6 voltage detecting circuit characteristics page 320 ra005 level of detected voltage operating voltage power supply voltage (v dd ) signal to request the voltage detection interrupt t vlton t vltpw t vltoff v oltage detection reset signal
22.7 ac characteristics (v ss = 0 v, v dd = 4.3 v to 5.5 v, topr = ?40 to 85c) parameter symbol condition min typ. max unit machine cycle time t cy normal1, 2 modes 0.100 ? 4 s idle0, 1, 2 modes slow1, 2 modes 117.6 ? 133.3 sleep0, 1 modes high-level clock pulse width t wch for external clock operation (xin input). fc = 10.0 mhz ? 50.0 ? ns low-level clock pulse width t wcl high-level clock pulse width t wsh for external clock operation (xtin input) fs = 32.768 khz ? 15.26 ? s low-level clock pulse width t wsl (v ss = 0 v, v dd = 2.7 v to 4.3 v, topr = ?40 to 85c) parameter symbol condition min typ. max unit machine cycle time t cy normal1, 2 modes 0.238 ? 4 s idle0, 1, 2 modes slow1, 2 modes 117.6 ? 133.3 sleep0, 1 modes high-level clock pulse width t wch for external clock operation (xin input). fc = 10.0 mhz ? 50.0 ? ns low-level clock pulse width t wcl high-level clock pulse width t wsh for external clock operation (xtin input) fs = 32.768 khz ? 15.26 ? s low-level clock pulse width t wsl (v ss = 0 v, v dd = 2.2 v to 2.7 v, topr = ?40 to 85c) parameter symbol condition min typ. max unit machine cycle time t cy normal1, 2 modes 0.500 ? 4 s idle0, 1, 2 modes slow1, 2 modes 117.6 ? 133.3 sleep0, 1 modes high-level clock pulse width t wch for external clock operation (xin input). fc = 8.0 mhz ? 62.5 ? ns low-level clock pulse width t wcl high-level clock pulse width t wsh for external clock operation (xtin input) fs = 32.768 khz ? 15.26 ? s low-level clock pulse width t wsl tmp89ch42 page 321 ra005
22.8 oscillating condition note 1: to ensure stable oscillation, the resonator position, load capacitance, etc. must be appropriate. because these factors are greatly affected by board patterns, please be sure to evaluate operation on the board on which the device will actually be mounted. note 2: the product numbers and specifications of the resonators supplied by murata manufacturing co., ltd. are subject to change. for up to date information, please refer to the following http://www.murata.com tmp89ch42 22. electrical characteristics 22.8 oscillating condition page 322 ra005 (2) low-frequency oscillation (1) high-frequency oscillation xin xout c 2 c 1 xtin xtout c 2 c 1
22.9 handling precaution - the solderability test conditions are shown below. 1. when using the sn-37pb solder bath solder bath temperature = 230c dipping time = 5 seconds number of times = once r-type flux used 2. when using the sn-3.0ag-0.5cu solder bath solder bath temperature = 245c dipping time = 5 seconds number of times = once r-type flux used the pass criteron of the above test is as follows: solderability rate until forming 95% - when using the device (oscillator) in places exposed to high electric fields such as cathode-ray tubes, we recommend electrically shielding the package in order to maintain normal operating condition. tmp89ch42 page 323 ra005
22.10 revision history rev description ra003 "22.4 ad conversion characteristics" revised description for ad conversion error. ra004 "22.5 power-on reset circuit characteristics" revised spec of power-on reset detecting voltage (v pron ). "22.3 dc characteristics" added note 3. ra005 "22.9 handling precaution" revised mark of lead-free. tmp89ch42 22. electrical characteristics 22.10 revision history page 324 ra005
23. package dimensions tmp89ch42 page 325 ra000 0.37 12.0 0.2 10.0 0.2 12.0 0.2 10.0 0.2 0.6 0.15 0.25 0.145 0.055 0.1 1.6max 0.05 1.4 0.05 0.08 0.07 0.2 0.8 1.0typ lqfp44-p-1010-0.80b rev 01 unit: mm
tmp89ch42 23. package dimensions page 326 ra000
restrictions on product use ? toshiba corporation, and its subsidiaries and affiliates (collectively ?toshiba?), reserve the right to make changes to the in formation in this document, and related hardware, software and systems (collectively ?product?) without notice. ? this document and any information herein may not be reproduced without prior written permission from toshiba. even with toshiba?s written permission, reproduction is permissible only if reproduction is without alteration/omission. ? though toshiba works continually to improve product?s quality and reliability, product can malfunction or fail. customers are responsible for complying with safety standards and for providing adequate designs and safeguards for their hardware, software and systems which minimize risk and avoid situations in which a malfunction or failure of product could cause loss of human life, b odily injury or damage to property, including data loss or corruption. before customers use the product, create designs including the product, or incorporate the product into their own applications, customers must also refer to and comply with (a) the latest versions of all relevant toshiba information, including without limitation, this document, the specifications, the data sheets and application notes for product and the precautions and conditions set forth in the ?toshiba semiconductor reliability handbook? and (b) the instructio ns for the application that product will be used with or for. customers are solely responsible for all aspects of their own product de sign or applications, including but not limited to (a) determining the appropriateness of the use of this product in such design or app lications; (b) evaluating and determining the applicability of any information contained in this document, or in charts, diagrams, program s, algorithms, sample application circuits, or any other referenced documents; and (c) validating all operating parameters for suc h designs and applications. toshiba assumes no liability for customers? product design or applications. ? product is intended for use in general electronics applications (e.g., computers, personal equipment, office equipment, measur ing equipment, industrial robots and home electronics appliances) or for specific applications as expressly stated in this document . product is neither intended nor warranted for use in equipment or systems that require extraordinarily high levels of quality a nd/or reliability and/or a malfunction or failure of which may cause lo ss of human life, bodily injury, serious property damage or se rious public impact (?unintended use?). unintended use includes, without limitation, equipment used in nuclear facilities, equipment used in the aerospace industry, medical equipment, equipment used for automobiles, trains, ships and other transportation, traffic signalin g equipment, equipment used to control combustions or explosions, safety devices, elevators and escalators, devices related to el ectric power, and equipment used in finance-related fields. do not use product for unintended use unless specifically permitted in thi s document. ? do not disassemble, analyze, reverse-engineer, alter, modify, translate or copy product, whether in whole or in part. ? product shall not be used for or incorporated into any products or systems whose manufacture, use, or sale is prohibited under any applicable laws or regulations. ? the information contained herein is pres ented only as guidance for product use. no responsibility is assumed by toshiba for an y infringement of patents or any other intellectual property rights of third parties that may result from the use of product. no license to any intellectual property right is granted by this document, whether express or implied, by estoppel or otherwise. ? absent a written signed agreement, except as provided in the relevant terms and conditions of sale for product, and to the maximum extent allowable by law, toshiba (1) assumes no liability whatsoever, including without limitation, indirect, consequential, special, or incidental damages or loss, including without limitation, loss of profits, loss of opportunities, business interruption and loss of data, and (2) disclaims any and all express or implied warranties and conditions related to sale, use of product, or information, including warranties or conditions of merchantability, fitness for a particular purpose, accuracy of information, or noninfringement. ? do not use or otherwise make available product or related software or technology for any military purposes, including without limitation, for the design, development, use, stockpiling or manufacturing of nuclear, chemical, or biological weapons or missile technolog y products (mass destruction weapons). product and related software and technology may be controlled under the japanese foreign exchange and foreign trade law and the u.s. export administration regulations. export and re-export of product or related softw are or technology are strictly prohibited except in compliance with all applicable export laws and regulations. ? please contact your toshiba sales representative for details as to environmental matters such as the rohs compatibility of pro duct. please use product in compliance with all applicable laws and regulations that regulate the inclusion or use of controlled subs tances, including without limitation, the eu rohs directive. toshiba assumes no liability for damages or losses occurring as a result o f noncompliance with applicable laws and regulations.


▲Up To Search▲   

 
Price & Availability of TMP89CH42UG

All Rights Reserved © IC-ON-LINE 2003 - 2022  

[Add Bookmark] [Contact Us] [Link exchange] [Privacy policy]
Mirror Sites :  [www.datasheet.hk]   [www.maxim4u.com]  [www.ic-on-line.cn] [www.ic-on-line.com] [www.ic-on-line.net] [www.alldatasheet.com.cn] [www.gdcy.com]  [www.gdcy.net]


 . . . . .
  We use cookies to deliver the best possible web experience and assist with our advertising efforts. By continuing to use this site, you consent to the use of cookies. For more information on cookies, please take a look at our Privacy Policy. X